You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/06/14 11:46:21 UTC

[03/21] mesos git commit: Update libprocess Once to use synchronized.

Update libprocess Once to use synchronized.

Review: https://reviews.apache.org/r/35093


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/149f42fd
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/149f42fd
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/149f42fd

Branch: refs/heads/master
Commit: 149f42fde28bf6eabb3fef0eea6eb86b85ca53e7
Parents: dc17126
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Sat Jun 13 06:14:50 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sun Jun 14 02:43:00 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/once.hpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/149f42fd/3rdparty/libprocess/include/process/once.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/once.hpp b/3rdparty/libprocess/include/process/once.hpp
index 256ed07..2b81df3 100644
--- a/3rdparty/libprocess/include/process/once.hpp
+++ b/3rdparty/libprocess/include/process/once.hpp
@@ -4,6 +4,7 @@
 #include <process/future.hpp>
 
 #include <stout/nothing.hpp>
+#include <stout/synchronized.hpp>
 
 namespace process {
 
@@ -32,8 +33,7 @@ public:
   {
     bool result = false;
 
-    pthread_mutex_lock(&mutex);
-    {
+    synchronized (mutex) {
       if (started) {
         while (!finished) {
           pthread_cond_wait(&cond, &mutex);
@@ -43,7 +43,6 @@ public:
         started = true;
       }
     }
-    pthread_mutex_unlock(&mutex);
 
     return result;
   }
@@ -51,14 +50,12 @@ public:
   // Transitions this Once instance to a 'done' state.
   void done()
   {
-    pthread_mutex_lock(&mutex);
-    {
+    synchronized (mutex) {
       if (started && !finished) {
         finished = true;
         pthread_cond_broadcast(&cond);
       }
     }
-    pthread_mutex_unlock(&mutex);
   }
 
 private: