Allow building with -Wmissing-noreturn
[folly.git] / folly / futures / SharedPromise.h
index 5fecffca8af4f7fc34f27def8228eb0a670ca49d..d1f8a94961621f442f9ec0b58e3ec4b2b5c2e153 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 #pragma once
 
 #include <folly/futures/Promise.h>
+#include <folly/Portability.h>
 
 namespace folly {
 
@@ -45,6 +46,13 @@ public:
   SharedPromise(SharedPromise<T>&&) noexcept;
   SharedPromise& operator=(SharedPromise<T>&&) noexcept;
 
+  /**
+   * Provide a way to split a Future<T>. Note that while the Futures from
+   * `getFuture()' depend on the completion of the parameter Future they do not
+   * inherit any other properties such as Executor's passed to `via' etc.
+   */
+  explicit SharedPromise(Future<T>);
+
   /**
    * Return a Future tied to the shared core state. Unlike Promise::getFuture,
    * this can be called an unlimited number of times per SharedPromise.
@@ -64,7 +72,8 @@ public:
       p.setException(std::current_exception());
     }
     */
-  DEPRECATED void setException(std::exception_ptr const&);
+  FOLLY_DEPRECATED("use setException(exception_wrapper)")
+  void setException(std::exception_ptr const&);
 
   /** Fulfill the SharedPromise with an exception type E, which can be passed to
     std::make_exception_ptr(). Useful for originating exceptions. If you
@@ -103,12 +112,15 @@ public:
   template <class F>
   void setWith(F&& func);
 
+  bool isFulfilled();
+
 private:
   std::mutex mutex_;
   size_t size_{0};
   bool hasValue_{false};
   Try<T> try_;
   std::vector<Promise<T>> promises_;
+  std::function<void(exception_wrapper const&)> interruptHandler_;
 };
 
 }