From 0a16e53b40d347db7dcd04cb694d0f8f2ed1a5a7 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 6 Oct 2016 21:13:04 +0200 Subject: Fix C++11 Windows build of threading code The initial problem was that mutex_auto_lock.h tries to use std::unique_lock 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. --- src/threading/event.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/threading/event.cpp') 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); -- cgit v1.2.3