Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / include / fwl / core / fwl_thread.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FWL_THREAD_H\r
8 #define _FWL_THREAD_H\r
9 class IFWL_NoteDriver;\r
10 class IFWL_Thread;\r
11 class IFWL_NoteThread;\r
12 typedef struct _FWL_HTHREAD {\r
13     FX_LPVOID pData;\r
14 } *FWL_HTHREAD;\r
15 class IFWL_Thread\r
16 {\r
17 public:\r
18     static IFWL_Thread * Create();\r
19 protected:\r
20     virtual ~IFWL_Thread() {}\r
21 public:\r
22     virtual void        Release() = 0;\r
23     virtual FWL_ERR Run(FWL_HTHREAD hThread) = 0;\r
24 };\r
25 FWL_HTHREAD FWL_StartThread(IFWL_Thread *pThread, FX_BOOL bSuspended = FALSE);\r
26 FWL_ERR FWL_ResumeThread(FWL_HTHREAD hThread);\r
27 FWL_ERR FWL_SuspendThread(FWL_HTHREAD hThread);\r
28 FWL_ERR FWL_KillThread(FWL_HTHREAD hThread, int32_t iExitCode);\r
29 FWL_ERR FWL_StopThread(FWL_HTHREAD hThread, int32_t iExitCode);\r
30 FWL_ERR FWL_Sleep(FX_DWORD dwMilliseconds);\r
31 class IFWL_NoteThread : public IFWL_Thread\r
32 {\r
33 public:\r
34     static IFWL_NoteThread* Create();\r
35     virtual FWL_ERR Run(FWL_HTHREAD hThread) = 0;\r
36     virtual IFWL_NoteDriver* GetNoteDriver() = 0;\r
37 };\r
38 typedef struct _FWL_HMUTEX {\r
39     FX_LPVOID pData;\r
40 } *FWL_HMUTEX;\r
41 FWL_HMUTEX      FWL_CreateMutex();\r
42 FWL_ERR         FWL_DestroyMutex(FWL_HMUTEX hMutex);\r
43 FWL_ERR         FWL_LockMutex(FWL_HMUTEX hMutex);\r
44 FWL_ERR         FWL_TryLockMutex(FWL_HMUTEX hMutex);\r
45 FWL_ERR         FWL_UnlockMutex(FWL_HMUTEX hMutex);\r
46 FWL_ERR         FWL_IsLockedMutex(FWL_HMUTEX hMutex, FX_BOOL &bLocked);\r
47 typedef struct _FWL_HSEMAPHORE {\r
48     FX_LPVOID pData;\r
49 } *FWL_HSEMAPHORE;\r
50 FWL_HSEMAPHORE  FWL_CreateSemaphore();\r
51 FWL_ERR         FWL_DestroySemaphore(FWL_HSEMAPHORE hSemaphore);\r
52 FWL_ERR         FWL_WaitSemaphore(FWL_HSEMAPHORE hSemaphore);\r
53 FWL_ERR         FWL_PostSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t down = 1);\r
54 FWL_ERR         FWL_GetSemaphoreValue(FWL_HSEMAPHORE hSemaphore, int32_t &value);\r
55 FWL_ERR         FWL_ResetSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t init);\r
56 #endif\r