}
template <class T>
-void Promise<T>::fulfilTry(Try<T>&& t) {
+void Promise<T>::fulfilTry(Try<T> t) {
throwIfFulfilled();
core_->setResult(std::move(t));
}
template <class M>
void setValue(M&& value);
- void fulfilTry(Try<T>&& t);
+ void fulfilTry(Try<T> t);
/** Fulfil this Promise with the result of a function that takes no
arguments and returns something implicitly convertible to T.
void runLoopCallback() noexcept override {
MoveWrapper<std::vector<Promise<void>>> promises(std::move(promises_));
- ctx_->fireWrite(std::move(sends_)).then([promises](Try<void>&& t) mutable {
- try {
- t.throwIfFailed();
- for (auto& p : *promises) {
- p.setValue();
- }
- } catch (...) {
- for (auto& p : *promises) {
- p.setException(std::current_exception());
- }
+ ctx_->fireWrite(std::move(sends_)).then([promises](Try<void> t) mutable {
+ for (auto& p : *promises) {
+ p.fulfilTry(t);
}
});
}