summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/IsThread.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-10-19 01:29:34 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-10-19 01:29:34 +0200
commit6d5a8892f34f4034b38da467268de9d489e1024e (patch)
tree787fe7d59be7e54a74fcc597eb6e59cf4523ee67 /src/OSSupport/IsThread.h
parentInfoDump: Fixed trailing whitespace. (diff)
downloadcuberite-6d5a8892f34f4034b38da467268de9d489e1024e.tar
cuberite-6d5a8892f34f4034b38da467268de9d489e1024e.tar.gz
cuberite-6d5a8892f34f4034b38da467268de9d489e1024e.tar.bz2
cuberite-6d5a8892f34f4034b38da467268de9d489e1024e.tar.lz
cuberite-6d5a8892f34f4034b38da467268de9d489e1024e.tar.xz
cuberite-6d5a8892f34f4034b38da467268de9d489e1024e.tar.zst
cuberite-6d5a8892f34f4034b38da467268de9d489e1024e.zip
Diffstat (limited to 'src/OSSupport/IsThread.h')
-rw-r--r--src/OSSupport/IsThread.h44
1 files changed, 2 insertions, 42 deletions
diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h
index 5de5f31c4..8dfad84cb 100644
--- a/src/OSSupport/IsThread.h
+++ b/src/OSSupport/IsThread.h
@@ -44,53 +44,13 @@ public:
/// 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);
/** Returns true if the thread calling this function is the thread contained within this object. */
- bool IsCurrentThread(void) const;
+ bool IsCurrentThread(void) const { return std::this_thread::get_id() == m_Thread.get_id(); }
protected:
AString m_ThreadName;
-
- // Value used for "no handle":
- #ifdef _WIN32
- #define NULL_HANDLE NULL
- #else
- #define NULL_HANDLE 0
- #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();
- return NULL;
- }
-
- #endif // else _WIN32
+ std::thread m_Thread;
} ;