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.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/threading/event.h') diff --git a/src/threading/event.h b/src/threading/event.h index dd5164576..26cb8997a 100644 --- a/src/threading/event.h +++ b/src/threading/event.h @@ -26,17 +26,12 @@ DEALINGS IN THE SOFTWARE. #ifndef THREADING_EVENT_H #define THREADING_EVENT_H -#if __cplusplus >= 201103L +#include "threads.h" + +#if USE_CPP11_MUTEX #include #include "threading/mutex.h" #include "threading/mutex_auto_lock.h" -#elif defined(_WIN32) - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - #include -#else - #include #endif @@ -49,18 +44,18 @@ DEALINGS IN THE SOFTWARE. class Event { public: Event(); -#if __cplusplus < 201103L +#ifndef USE_CPP11_MUTEX ~Event(); #endif void wait(); void signal(); private: -#if __cplusplus >= 201103L +#if USE_CPP11_MUTEX std::condition_variable cv; Mutex mutex; bool notified; -#elif defined(_WIN32) +#elif USE_WIN_MUTEX HANDLE event; #else pthread_cond_t cv; -- cgit v1.2.3