diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-11-28 08:37:50 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-11-28 08:39:41 +0100 |
commit | 26efc220a13aa3413f6e55e311e8991445104f82 (patch) | |
tree | e9513ed2b658d0bfdd89b5e79bfcee0e3a3f0f13 /src/sync.h | |
parent | a89221873a3ee2451c73b41bbe2d99d36f439d31 (diff) | |
parent | f7f7e2cd340c088e82d09090eb275b98b34a9812 (diff) |
Merge #11722: Switched sync.{cpp,h} to std threading primitives.
f7f7e2c threads: add a thread_local autoconf check (Cory Fields)
bba9bd0 Switched sync.{cpp,h} to std threading primitives. (Thomas Snider)
Pull request description:
Replaced boost threading primitives with the std equivalents.
Tree-SHA512: 72d10f9e48bfcf1db87e4a88bc698ef98eba0b29fe904570391b34a6ea1ffad474b7f192e70e3588a30e448f70f244eb4ddc5f24412a0bde2b564e76274160a5
Diffstat (limited to 'src/sync.h')
-rw-r--r-- | src/sync.h | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/sync.h b/src/sync.h index b0889be767..3af27c65d0 100644 --- a/src/sync.h +++ b/src/sync.h @@ -8,8 +8,6 @@ #include <threadsafety.h> -#include <boost/thread/condition_variable.hpp> -#include <boost/thread/mutex.hpp> #include <condition_variable> #include <thread> #include <mutex> @@ -196,8 +194,8 @@ public: class CSemaphore { private: - boost::condition_variable condition; - boost::mutex mutex; + std::condition_variable condition; + std::mutex mutex; int value; public: @@ -205,16 +203,14 @@ public: void wait() { - boost::unique_lock<boost::mutex> lock(mutex); - while (value < 1) { - condition.wait(lock); - } + std::unique_lock<std::mutex> lock(mutex); + condition.wait(lock, [&]() { return value >= 1; }); value--; } bool try_wait() { - boost::unique_lock<boost::mutex> lock(mutex); + std::lock_guard<std::mutex> lock(mutex); if (value < 1) return false; value--; @@ -224,7 +220,7 @@ public: void post() { { - boost::unique_lock<boost::mutex> lock(mutex); + std::lock_guard<std::mutex> lock(mutex); value++; } condition.notify_one(); |