Roll forward to cl/336363104

Signed-off-by: hai007 <hais@google.com>
This commit is contained in:
hai007
2020-10-09 14:14:41 -07:00
parent bcc3f21da2
commit 0738d06b0a
31 changed files with 728 additions and 254 deletions
+8 -2
View File
@@ -25,8 +25,9 @@ class SettableFuture : public api::SettableFuture<T> {
exception_ = {Exception::kSuccess};
completed_.Notify();
InvokeAllLocked();
return true;
}
return true;
return false;
}
void AddListener(Runnable runnable, api::Executor* executor) override {
@@ -38,6 +39,11 @@ class SettableFuture : public api::SettableFuture<T> {
}
}
bool IsSet() const {
MutexLock lock(&mutex_);
return done_;
}
bool SetException(Exception exception) override {
MutexLock lock(&mutex_);
return SetExceptionLocked(exception);
@@ -94,7 +100,7 @@ class SettableFuture : public api::SettableFuture<T> {
listeners_.clear();
}
Mutex mutex_;
mutable Mutex mutex_;
ConditionVariable completed_{&mutex_};
std::vector<std::pair<api::Executor*, std::function<void()>>> listeners_;
bool done_{false};