aboutsummaryrefslogtreecommitdiff
path: root/src/threading/thread.h
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2016-03-07 16:55:32 -0500
committerShadowNinja <shadowninja@minetest.net>2016-04-28 13:21:46 -0400
commit46fd114e9a4e05b74576dce682e24357363298e7 (patch)
tree78eebcdc7f2b76c52ed4ad0b85600cdfcbcce018 /src/threading/thread.h
parente41673820ffe200df78b1ec185ccb9d9ca962ae1 (diff)
downloadhax-minetest-server-46fd114e9a4e05b74576dce682e24357363298e7.tar.gz
hax-minetest-server-46fd114e9a4e05b74576dce682e24357363298e7.zip
Fix race on thread creation
This often broke the threading tests on OSX.
Diffstat (limited to 'src/threading/thread.h')
-rw-r--r--src/threading/thread.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/threading/thread.h b/src/threading/thread.h
index 6a24afffb..10732c442 100644
--- a/src/threading/thread.h
+++ b/src/threading/thread.h
@@ -90,12 +90,22 @@ public:
/*
* Returns true if the calling thread is this Thread object.
*/
- bool isCurrentThread();
+ bool isCurrentThread() { return thr_is_current_thread(getThreadId()); }
inline bool isRunning() { return m_running; }
inline bool stopRequested() { return m_request_stop; }
+
+#if USE_CPP11_THREADS
+ inline threadid_t getThreadId() { return m_thread_obj->get_id(); }
+ inline threadhandle_t getThreadHandle() { return m_thread_obj->native_handle(); }
+#else
+# if USE_WIN_THREADS
inline threadid_t getThreadId() { return m_thread_id; }
+# else
+ inline threadid_t getThreadId() { return m_thread_handle; }
+# endif
inline threadhandle_t getThreadHandle() { return m_thread_handle; }
+#endif
/*
* Gets the thread return value.
@@ -147,8 +157,12 @@ private:
Atomic<bool> m_running;
Mutex m_mutex;
- threadid_t m_thread_id;
+#if !USE_CPP11_THREADS
threadhandle_t m_thread_handle;
+#if _WIN32
+ threadid_t m_thread_id;
+#endif
+#endif
static ThreadStartFunc threadProc;