summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-05-06 13:39:43 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-05-08 11:22:08 -0700
commita37092f9f31fbc11a101f1cc30baf15effabd8c6 (patch)
tree5ea6c001ce4201755d90003318da64864aa3e2c9
parentf28df17be9c365d64a51d41a6cf244c0c905cd5e (diff)
downloadceph-a37092f9f31fbc11a101f1cc30baf15effabd8c6.tar.gz
RefCounteCond: keep return val, wait() returns it
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>
-rw-r--r--src/common/RefCountedObj.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/common/RefCountedObj.h b/src/common/RefCountedObj.h
index 4bbbc8dfa61..042adb58780 100644
--- a/src/common/RefCountedObj.h
+++ b/src/common/RefCountedObj.h
@@ -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);
+ }
};
/**