misc/libphysfs/lzma/CPP/Windows/Thread.h
changeset 13881 99b265e0d1d0
parent 13880 5f819b90d479
child 13882 b172a5d40eee
equal deleted inserted replaced
13880:5f819b90d479 13881:99b265e0d1d0
     1 // Windows/Thread.h
       
     2 
       
     3 #ifndef __WINDOWS_THREAD_H
       
     4 #define __WINDOWS_THREAD_H
       
     5 
       
     6 #include "Defs.h"
       
     7 
       
     8 extern "C" 
       
     9 { 
       
    10 #include "../../C/Threads.h"
       
    11 }
       
    12 
       
    13 namespace NWindows {
       
    14 
       
    15 class CThread
       
    16 {
       
    17   ::CThread thread;
       
    18 public:
       
    19   CThread() { Thread_Construct(&thread); }
       
    20   ~CThread() { Close(); }
       
    21   bool IsCreated() { return Thread_WasCreated(&thread) != 0; }
       
    22   HRes Close()  { return Thread_Close(&thread); }
       
    23   HRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
       
    24     { return Thread_Create(&thread, startAddress, parameter); }
       
    25   HRes Wait() { return Thread_Wait(&thread); }
       
    26   
       
    27   #ifdef _WIN32
       
    28   DWORD Resume() { return ::ResumeThread(thread.handle); }
       
    29   DWORD Suspend() { return ::SuspendThread(thread.handle); }
       
    30   bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread.handle, exitCode)); }
       
    31   int GetPriority() { return ::GetThreadPriority(thread.handle); }
       
    32   bool SetPriority(int priority) { return BOOLToBool(::SetThreadPriority(thread.handle, priority)); }
       
    33   #endif
       
    34 };
       
    35 
       
    36 }
       
    37 
       
    38 #endif