cmake: add checks to generate folly-config.h correctly
[folly.git] / folly / futures / Promise.h
index 75119129df82a69a65f2e8dc6298c0d16f0351e9..359651324c19c15b3ce8a5907ed29a720b914543 100644 (file)
 namespace folly {
 
 // forward declaration
+template <class T>
+class SemiFuture;
 template <class T> class Future;
 
+namespace futures {
 namespace detail {
+template <class T>
+class FutureBase;
 struct EmptyConstruct {};
 template <typename T, typename F>
 class CoreCallbackState;
-}
+} // namespace detail
+} // namespace futures
 
 template <class T>
 class Promise {
  public:
+  static Promise<T> makeEmpty() noexcept; // equivalent to moved-from
+
   Promise();
   ~Promise();
 
@@ -45,8 +53,15 @@ class Promise {
   Promise(Promise<T>&&) noexcept;
   Promise& operator=(Promise<T>&&) noexcept;
 
+  /** Return a SemiFuture tied to the shared core state. This can be called only
+    once, thereafter FutureAlreadyRetrieved exception will be raised. */
+  SemiFuture<T> getSemiFuture();
+
   /** Return a Future tied to the shared core state. This can be called only
-    once, thereafter Future already retrieved exception will be raised. */
+    once, thereafter FutureAlreadyRetrieved exception will be raised.
+    NOTE: This function is deprecated. Please use getSemiFuture and pass the
+          appropriate executor to .via on the returned SemiFuture to get a
+          valid Future where necessary. */
   Future<T> getFuture();
 
   /** Fulfill the Promise with an exception_wrapper */
@@ -103,9 +118,14 @@ class Promise {
 
  private:
   typedef typename Future<T>::corePtr corePtr;
-  template <class> friend class Future;
+  template <class>
+  friend class futures::detail::FutureBase;
+  template <class>
+  friend class SemiFuture;
+  template <class>
+  friend class Future;
   template <class, class>
-  friend class detail::CoreCallbackState;
+  friend class futures::detail::CoreCallbackState;
 
   // Whether the Future has been retrieved (a one-time operation).
   bool retrieved_;
@@ -113,14 +133,14 @@ class Promise {
   // shared core state object
   corePtr core_;
 
-  explicit Promise(detail::EmptyConstruct) noexcept;
+  explicit Promise(futures::detail::EmptyConstruct) noexcept;
 
   void throwIfFulfilled();
   void throwIfRetrieved();
   void detach();
 };
 
-}
+} // namespace folly
 
 #include <folly/futures/Future.h>
 #include <folly/futures/Promise-inl.h>