summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/IsThread.h
diff options
context:
space:
mode:
authorSteven Riehl <sriehl@gmail.com>2014-10-12 04:39:55 +0200
committerSteven Riehl <sriehl@gmail.com>2014-10-12 04:39:55 +0200
commit856764dee8f0c66397669e8c7c013c758f1d2c81 (patch)
tree4d8e3f0a63410b99728929ef1ce220c5392d5bf5 /src/OSSupport/IsThread.h
parentUpdate README.md (diff)
downloadcuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.tar
cuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.tar.gz
cuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.tar.bz2
cuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.tar.lz
cuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.tar.xz
cuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.tar.zst
cuberite-856764dee8f0c66397669e8c7c013c758f1d2c81.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/IsThread.h36
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
-
-
-
-