annotate src/win32/7zip/7z/CPP/Windows/Thread.h @ 5:8fe0c57e53d2

concentrating on lua first
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:39:40 -0600
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 // Windows/Thread.h
rlm@1 2
rlm@1 3 #ifndef __WINDOWS_THREAD_H
rlm@1 4 #define __WINDOWS_THREAD_H
rlm@1 5
rlm@1 6 #include "Defs.h"
rlm@1 7
rlm@1 8 extern "C"
rlm@1 9 {
rlm@1 10 #include "../../C/Threads.h"
rlm@1 11 }
rlm@1 12
rlm@1 13 namespace NWindows {
rlm@1 14
rlm@1 15 class CThread
rlm@1 16 {
rlm@1 17 ::CThread thread;
rlm@1 18 public:
rlm@1 19 CThread() { Thread_Construct(&thread); }
rlm@1 20 ~CThread() { Close(); }
rlm@1 21 bool IsCreated() { return Thread_WasCreated(&thread) != 0; }
rlm@1 22 WRes Close() { return Thread_Close(&thread); }
rlm@1 23 WRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
rlm@1 24 { return Thread_Create(&thread, startAddress, parameter); }
rlm@1 25 WRes Wait() { return Thread_Wait(&thread); }
rlm@1 26
rlm@1 27 #ifdef _WIN32
rlm@1 28 DWORD Resume() { return ::ResumeThread(thread.handle); }
rlm@1 29 DWORD Suspend() { return ::SuspendThread(thread.handle); }
rlm@1 30 bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread.handle, exitCode)); }
rlm@1 31 int GetPriority() { return ::GetThreadPriority(thread.handle); }
rlm@1 32 bool SetPriority(int priority) { return BOOLToBool(::SetThreadPriority(thread.handle, priority)); }
rlm@1 33 #endif
rlm@1 34 };
rlm@1 35
rlm@1 36 }
rlm@1 37
rlm@1 38 #endif