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>
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);
+ }
};
/**