/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
std::swap(size_, other.size_);
std::swap(hasValue_, other.hasValue_);
std::swap(try_, other.try_);
+ std::swap(interruptHandler_, other.interruptHandler_);
std::swap(promises_, other.promises_);
return *this;
return makeFuture<T>(Try<T>(try_));
} else {
promises_.emplace_back();
+ if (interruptHandler_) {
+ promises_.back().setInterruptHandler(interruptHandler_);
+ }
return promises_.back().getFuture();
}
}
if (hasValue_) {
return;
}
+ interruptHandler_ = fn;
for (auto& p : promises_) {
p.setInterruptHandler(fn);
}
template <class T>
bool SharedPromise<T>::isFulfilled() {
+ std::lock_guard<std::mutex> g(mutex_);
return hasValue_;
}