]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
RefCounteCond: keep return val, wait() returns it
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 6 May 2013 20:39:43 +0000 (13:39 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 8 May 2013 18:22:08 +0000 (11:22 -0700)
It is necessary in some cases to notify waiters of the
actual return value for the action they were waiting on.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/RefCountedObj.h

index 4bbbc8dfa61d211ea807fee4c56b7ddf0d8012cb..042adb587806885b9b01c54830dab0410825ad48 100644 (file)
@@ -47,21 +47,28 @@ struct RefCountedCond : public RefCountedObject {
   bool complete;
   Mutex lock;
   Cond cond;
+  int rval;
 
-  RefCountedCond() : complete(false), lock("RefCountedCond") {}
+  RefCountedCond() : complete(false), lock("RefCountedCond"), rval(0) {}
 
-  void wait() {
+  int wait() {
     Mutex::Locker l(lock);
     while (!complete) {
       cond.Wait(lock);
     }
+    return rval;
   }
 
-  void done() {
+  void done(int r) {
     Mutex::Locker l(lock);
+    rval = r;
     complete = true;
     cond.SignalAll();
   }
+
+  void done() {
+    done(0);
+  }
 };
 
 /**