From: Yehuda Sadeh Date: Mon, 6 May 2013 20:39:43 +0000 (-0700) Subject: RefCounteCond: keep return val, wait() returns it X-Git-Tag: v0.67-rc1~128^2~143 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a37092f9f31fbc11a101f1cc30baf15effabd8c6;p=ceph.git 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 --- 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); + } }; /**