diff options
author | Mattes D <github@xoft.cz> | 2014-10-21 18:12:40 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-10-21 18:12:40 +0200 |
commit | bcb839d07bd9b0cea4cd8af021db76ae0822f7a9 (patch) | |
tree | 1970b9d1650e63ed5bec88308d70736d13463e09 /src/OSSupport/IsThread.h | |
parent | Updated ProtectionAreas (diff) | |
parent | fix std:min call, include algorithm and compare same type (diff) | |
download | cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.tar cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.tar.gz cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.tar.bz2 cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.tar.lz cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.tar.xz cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.tar.zst cuberite-bcb839d07bd9b0cea4cd8af021db76ae0822f7a9.zip |
Diffstat (limited to 'src/OSSupport/IsThread.h')
-rw-r--r-- | src/OSSupport/IsThread.h | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h index 5de5f31c4..5c8d28d2d 100644 --- a/src/OSSupport/IsThread.h +++ b/src/OSSupport/IsThread.h @@ -31,20 +31,20 @@ protected: /// The overriden Execute() method should check this value periodically and terminate if this is true volatile bool m_ShouldTerminate; - + public: cIsThread(const AString & iThreadName); virtual ~cIsThread(); - + /// Starts the thread; returns without waiting for the actual start bool Start(void); - + /// Signals the thread to terminate and waits until it's finished void Stop(void); - + /// Waits for the thread to finish. Doesn't signalize the ShouldTerminate flag bool Wait(void); - + /// Returns the OS-dependent thread ID for the caller's thread static unsigned long GetCurrentID(void); @@ -53,7 +53,7 @@ public: protected: AString m_ThreadName; - + // Value used for "no handle": #ifdef _WIN32 #define NULL_HANDLE NULL @@ -62,34 +62,34 @@ protected: #endif #ifdef _WIN32 - + DWORD m_ThreadID; HANDLE m_Handle; - + static DWORD __stdcall thrExecute(LPVOID a_Param) { // Create a window so that the thread can be identified by 3rd party tools: HWND IdentificationWnd = CreateWindowA("STATIC", ((cIsThread *)a_Param)->m_ThreadName.c_str(), 0, 0, 0, 0, WS_OVERLAPPED, NULL, NULL, NULL, NULL); - + // Run the thread: ((cIsThread *)a_Param)->Execute(); - + // Destroy the identification window: DestroyWindow(IdentificationWnd); - + return 0; } - + #else // _WIN32 - + pthread_t m_Handle; - + static void * thrExecute(void * a_Param) { - ((cIsThread *)a_Param)->Execute(); + (static_cast<cIsThread *>(a_Param))->Execute(); return NULL; } - + #endif // else _WIN32 } ; @@ -98,7 +98,3 @@ protected: #endif // CISTHREAD_H_INCLUDED - - - - |