mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From y..@apache.org
Subject [2/2] git commit: Improved gate.hpp documentation.
Date Thu, 03 Jul 2014 21:31:18 GMT
Improved gate.hpp documentation.

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


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

Branch: refs/heads/master
Commit: 6fb588a42ea699750fd6a81fa331f994802b066f
Parents: 936772e
Author: Jiang Yan Xu <yan@jxu.me>
Authored: Mon Jun 23 14:41:04 2014 -0700
Committer: Jiang Yan Xu <yan@jxu.me>
Committed: Thu Jul 3 14:30:58 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/gate.hpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6fb588a4/3rdparty/libprocess/src/gate.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/gate.hpp b/3rdparty/libprocess/src/gate.hpp
index 78f944c..69c906b 100644
--- a/3rdparty/libprocess/src/gate.hpp
+++ b/3rdparty/libprocess/src/gate.hpp
@@ -27,6 +27,8 @@ public:
     pthread_mutex_destroy(&mutex);
   }
 
+  // Signals the state change of the gate to any (at least one) or
+  // all (if 'all' is true) of the threads waiting on it.
   void open(bool all = true)
   {
     pthread_mutex_lock(&mutex);
@@ -38,6 +40,8 @@ public:
     pthread_mutex_unlock(&mutex);
   }
 
+  // Blocks the current thread until the gate's state changes from
+  // the current state.
   void wait()
   {
     pthread_mutex_lock(&mutex);
@@ -52,6 +56,9 @@ public:
     pthread_mutex_unlock(&mutex);
   }
 
+  // Gets the current state of the gate and notifies the gate about
+  // the intention to wait for its state change.
+  // Call 'leave()' if no longer interested in the state change.
   state_t approach()
   {
     state_t old;
@@ -64,6 +71,9 @@ public:
     return old;
   }
 
+  // Blocks the current thread until the gate's state changes from
+  // the specified 'old' state. The 'old' state can be obtained by
+  // calling 'approach()'.
   void arrive(state_t old)
   {
     pthread_mutex_lock(&mutex);
@@ -76,6 +86,8 @@ public:
     pthread_mutex_unlock(&mutex);
   }
 
+  // Notifies the gate that a waiter (the current thread) is no
+  // longer waiting for the gate's state change.
   void leave()
   {
     pthread_mutex_lock(&mutex);
@@ -85,6 +97,8 @@ public:
     pthread_mutex_unlock(&mutex);
   }
 
+  // Returns true if there is no one waiting on the gate's state
+  // change.
   bool empty()
   {
     bool occupied = true;


Mime
View raw message