summaryrefslogtreecommitdiff
path: root/src/threading/thread.h
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2016-10-06 21:13:04 +0200
committersfan5 <sfan5@live.de>2016-10-06 22:37:30 +0200
commit0a16e53b40d347db7dcd04cb694d0f8f2ed1a5a7 (patch)
treee51a3209f5d3215bd9ab55311b0e4702ce3e9fca /src/threading/thread.h
parent155288ee981c70f505526347cb2bcda4df1c8e6b (diff)
downloadminetest-0a16e53b40d347db7dcd04cb694d0f8f2ed1a5a7.tar.gz
minetest-0a16e53b40d347db7dcd04cb694d0f8f2ed1a5a7.tar.bz2
minetest-0a16e53b40d347db7dcd04cb694d0f8f2ed1a5a7.zip
Fix C++11 Windows build of threading code
The initial problem was that mutex_auto_lock.h tries to use std::unique_lock<std::mutex> despite mutex.h not using C++11's std::mutex on Windows. The problem here is the mismatch between C++11 usage conditions of the two headers. This commit moves the decision logic to threads.h and makes sure mutex.h, mutex_auto_lock.h and event.h all use the same features.
Diffstat (limited to 'src/threading/thread.h')
-rw-r--r--src/threading/thread.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/threading/thread.h b/src/threading/thread.h
index de800ecb7..14a0e13ab 100644
--- a/src/threading/thread.h
+++ b/src/threading/thread.h
@@ -32,9 +32,6 @@ DEALINGS IN THE SOFTWARE.
#include "threads.h"
#include <string>
-#if USE_CPP11_THREADS
- #include <thread> // for std::thread
-#endif
#ifdef _AIX
#include <sys/thread.h> // for tid_t
#endif
@@ -157,9 +154,11 @@ private:
Atomic<bool> m_running;
Mutex m_mutex;
-#ifndef USE_CPP11_THREADS
+#if USE_CPP11_THREADS
+ std::thread *m_thread_obj;
+#else
threadhandle_t m_thread_handle;
-# if _WIN32
+# if USE_WIN_THREADS
threadid_t m_thread_id;
# endif
#endif
@@ -172,10 +171,6 @@ private:
tid_t m_kernel_thread_id;
#endif
-#if USE_CPP11_THREADS
- std::thread *m_thread_obj;
-#endif
-
DISABLE_CLASS_COPY(Thread);
};