/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
template <class T>
-Future<T> SharedPromise<T>::getFuture() {
+SemiFuture<T> SharedPromise<T>::getSemiFuture() {
std::lock_guard<std::mutex> g(mutex_);
size_++;
if (hasValue_) {
if (interruptHandler_) {
promises_.back().setInterruptHandler(interruptHandler_);
}
- return promises_.back().getFuture();
+ return promises_.back().getSemiFuture();
}
}
+template <class T>
+Future<T> SharedPromise<T>::getFuture() {
+ return getSemiFuture().via(&folly::InlineExecutor::instance());
+}
+
template <class T>
template <class E>
typename std::enable_if<std::is_base_of<std::exception, E>::value>::type
{
std::lock_guard<std::mutex> g(mutex_);
if (hasValue_) {
- throw PromiseAlreadySatisfied();
+ throwPromiseAlreadySatisfied();
}
hasValue_ = true;
try_ = std::move(t);
template <class T>
bool SharedPromise<T>::isFulfilled() {
+ std::lock_guard<std::mutex> g(mutex_);
return hasValue_;
}
-}
+} // namespace folly