Roll forward to cl/336363104

Signed-off-by: hai007 <hais@google.com>
This commit is contained in:
hai007
2020-10-09 15:08:34 -07:00
30 changed files with 1303 additions and 0 deletions
+18
View File
@@ -39,8 +39,14 @@ class SettableFuture : public api::SettableFuture<T> {
exception_ = {Exception::kSuccess};
completed_.Notify();
InvokeAllLocked();
<<<<<<< HEAD
}
return true;
=======
return true;
}
return false;
>>>>>>> release
}
void AddListener(Runnable runnable, api::Executor* executor) override {
@@ -52,6 +58,14 @@ class SettableFuture : public api::SettableFuture<T> {
}
}
<<<<<<< HEAD
=======
bool IsSet() const {
MutexLock lock(&mutex_);
return done_;
}
>>>>>>> release
bool SetException(Exception exception) override {
MutexLock lock(&mutex_);
return SetExceptionLocked(exception);
@@ -108,7 +122,11 @@ class SettableFuture : public api::SettableFuture<T> {
listeners_.clear();
}
<<<<<<< HEAD
Mutex mutex_;
=======
mutable Mutex mutex_;
>>>>>>> release
ConditionVariable completed_{&mutex_};
std::vector<std::pair<api::Executor*, std::function<void()>>> listeners_;
bool done_{false};