mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user