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-06 13:39:43 -0700
commit8d09db614002a49011a372bc5e28fe294019f4b5 (patch)
treed5a31ee81016bcdc44776bf73e788b97a713c756
parent2984ff4bc4c990e53ff4c66816c948d0d9d2298f (diff)
downloadceph-8d09db614002a49011a372bc5e28fe294019f4b5.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);
+ }
};
/**