about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-24T12·31+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-24T12·31+0100
commitbf2adf72c4fb4e04afb95ad3b2ad84c19707f246 (patch)
treea8ed9da01f7be74cfa9a1402071b0b598ee9425f /src
parentccdbf589a47b486876de28a9beab64360ba8b8fc (diff)
std::condition_variable_any -> std::condition_variable
The latter is supposed to be more efficient.
Diffstat (limited to 'src')
-rw-r--r--src/libutil/pool.hh2
-rw-r--r--src/libutil/sync.hh20
2 files changed, 11 insertions, 11 deletions
diff --git a/src/libutil/pool.hh b/src/libutil/pool.hh
index b9eb2dd1ecce..f291cd578388 100644
--- a/src/libutil/pool.hh
+++ b/src/libutil/pool.hh
@@ -54,7 +54,7 @@ private:
 
     Sync<State> state;
 
-    std::condition_variable_any wakeup;
+    std::condition_variable wakeup;
 
 public:
 
diff --git a/src/libutil/sync.hh b/src/libutil/sync.hh
index 3abffa7c7437..c99c098ac9c6 100644
--- a/src/libutil/sync.hh
+++ b/src/libutil/sync.hh
@@ -38,37 +38,37 @@ public:
     {
     private:
         Sync * s;
+        std::unique_lock<std::mutex> lk;
         friend Sync;
-        Lock(Sync * s) : s(s) { s->mutex.lock(); }
+        Lock(Sync * s) : s(s), lk(s->mutex) { }
     public:
-        Lock(Lock && l) : s(l.s) { l.s = 0; }
+        Lock(Lock && l) : s(l.s) { abort(); }
         Lock(const Lock & l) = delete;
-        ~Lock() { if (s) s->mutex.unlock(); }
+        ~Lock() { }
         T * operator -> () { return &s->data; }
         T & operator * () { return s->data; }
 
-        /* FIXME: performance impact of condition_variable_any? */
-        void wait(std::condition_variable_any & cv)
+        void wait(std::condition_variable & cv)
         {
             assert(s);
-            cv.wait(s->mutex);
+            cv.wait(lk);
         }
 
         template<class Rep, class Period, class Predicate>
-        bool wait_for(std::condition_variable_any & cv,
+        bool wait_for(std::condition_variable & cv,
             const std::chrono::duration<Rep, Period> & duration,
             Predicate pred)
         {
             assert(s);
-            return cv.wait_for(s->mutex, duration, pred);
+            return cv.wait_for(lk, duration, pred);
         }
 
         template<class Clock, class Duration>
-        std::cv_status wait_until(std::condition_variable_any & cv,
+        std::cv_status wait_until(std::condition_variable & cv,
             const std::chrono::time_point<Clock, Duration> & duration)
         {
             assert(s);
-            return cv.wait_until(s->mutex, duration);
+            return cv.wait_until(lk, duration);
         }
     };