cmake: add checks to generate folly-config.h correctly
[folly.git] / folly / futures / Promise-inl.h
index 5fe4ed2cb029c782c39e3f54ac9fa2fdb0fc2222..45e6929a9152a7bc0bf4750cf7583e8da4a684e3 100644 (file)
@@ -19,6 +19,7 @@
 #include <atomic>
 #include <thread>
 
+#include <folly/executors/InlineExecutor.h>
 #include <folly/futures/FutureException.h>
 #include <folly/futures/detail/Core.h>
 
@@ -76,18 +77,26 @@ Promise<T>::~Promise() {
 template <class T>
 void Promise<T>::detach() {
   if (core_) {
-    if (!retrieved_)
+    if (!retrieved_) {
       core_->detachFuture();
+    }
     core_->detachPromise();
     core_ = nullptr;
   }
 }
 
 template <class T>
-Future<T> Promise<T>::getFuture() {
+SemiFuture<T> Promise<T>::getSemiFuture() {
   throwIfRetrieved();
   retrieved_ = true;
-  return Future<T>(core_);
+  return SemiFuture<T>(core_);
+}
+
+template <class T>
+Future<T> Promise<T>::getFuture() {
+  // An InlineExecutor approximates the old behaviour of continuations
+  // running inine on setting the value of the promise.
+  return getSemiFuture().via(&InlineExecutor::instance());
 }
 
 template <class T>
@@ -144,4 +153,4 @@ bool Promise<T>::isFulfilled() const noexcept {
   return true;
 }
 
-}
+} // namespace folly