diff options
author | sfan5 <sfan5@live.de> | 2016-10-06 21:13:04 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2016-10-06 22:37:30 +0200 |
commit | 0a16e53b40d347db7dcd04cb694d0f8f2ed1a5a7 (patch) | |
tree | e51a3209f5d3215bd9ab55311b0e4702ce3e9fca /src/threading/event.cpp | |
parent | 155288ee981c70f505526347cb2bcda4df1c8e6b (diff) | |
download | minetest-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/event.cpp')
-rw-r--r-- | src/threading/event.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/threading/event.cpp b/src/threading/event.cpp index 165f9d83f..0d5928f10 100644 --- a/src/threading/event.cpp +++ b/src/threading/event.cpp @@ -27,8 +27,8 @@ DEALINGS IN THE SOFTWARE. Event::Event() { -#if __cplusplus < 201103L -# ifdef _WIN32 +#ifndef USE_CPP11_MUTEX +# if USE_WIN_MUTEX event = CreateEvent(NULL, false, false, NULL); # else pthread_cond_init(&cv, NULL); @@ -38,10 +38,10 @@ Event::Event() #endif } -#if __cplusplus < 201103L +#ifndef USE_CPP11_MUTEX Event::~Event() { -#ifdef _WIN32 +#if USE_WIN_MUTEX CloseHandle(event); #else pthread_cond_destroy(&cv); @@ -53,13 +53,13 @@ Event::~Event() void Event::wait() { -#if __cplusplus >= 201103L +#if USE_CPP11_MUTEX MutexAutoLock lock(mutex); while (!notified) { cv.wait(lock); } notified = false; -#elif defined(_WIN32) +#elif USE_WIN_MUTEX WaitForSingleObject(event, INFINITE); #else pthread_mutex_lock(&mutex); @@ -74,11 +74,11 @@ void Event::wait() void Event::signal() { -#if __cplusplus >= 201103L +#if USE_CPP11_MUTEX MutexAutoLock lock(mutex); notified = true; cv.notify_one(); -#elif defined(_WIN32) +#elif USE_WIN_MUTEX SetEvent(event); #else pthread_mutex_lock(&mutex); |