Add deprecation comments to folly::makeFuture.
authorLee Howes <lwh@fb.com>
Wed, 27 Dec 2017 04:31:33 +0000 (20:31 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 27 Dec 2017 04:51:03 +0000 (20:51 -0800)
Summary:
To ensure that we do not end up with continuable futures without attached executors we should deprecate folly::makeFuture. In most cases folly::makeSemiFuture is adequate here.

This diff only adds comments to dissuade future use.

Reviewed By: yfeldblum

Differential Revision: D6628800

fbshipit-source-id: c2b91df351cc5980c1bfb752f7536d320ef8168a

folly/futures/helpers.h

index 9b5e85ba1f0ac96ede79a336389f34faa9645e63..eb5412b2cb2935af9f0478153661746b1b743770 100644 (file)
@@ -186,11 +186,21 @@ SemiFuture<T> makeSemiFuture(Try<T>&& t);
   or
 
     auto f = makeFuture<string>("foo");
+
+  NOTE: This function is deprecated. Please use makeSemiFuture and pass the
+       appropriate executor to .via on the returned SemiFuture to get a
+       valid Future where necessary.
 */
 template <class T>
 Future<typename std::decay<T>::type> makeFuture(T&& t);
 
-/** Make a completed void Future. */
+/**
+  Make a completed void Future.
+
+  NOTE: This function is deprecated. Please use makeSemiFuture and pass the
+       appropriate executor to .via on the returned SemiFuture to get a
+       valid Future where necessary.
+ */
 Future<Unit> makeFuture();
 
 /**
@@ -208,6 +218,10 @@ Future<Unit> makeFuture();
 
   Calling makeFutureWith(func) is equivalent to calling
   makeFuture().then(func).
+
+  NOTE: This function is deprecated. Please use makeSemiFutureWith and pass the
+       appropriate executor to .via on the returned SemiFuture to get a
+       valid Future where necessary.
 */
 
 // makeFutureWith(Future<T>()) -> Future<T>
@@ -229,21 +243,35 @@ makeFutureWith(F&& func);
 ///
 ///   auto f = makeFuture<string>(std::current_exception());
 template <class T>
-FOLLY_DEPRECATED("use makeFuture(exception_wrapper)")
+FOLLY_DEPRECATED("use makeSemiFuture(exception_wrapper)")
 Future<T> makeFuture(std::exception_ptr const& e);
 
 /// Make a failed Future from an exception_wrapper.
+/// NOTE: This function is deprecated. Please use makeSemiFuture and pass the
+///     appropriate executor to .via on the returned SemiFuture to get a
+///     valid Future where necessary.
 template <class T>
 Future<T> makeFuture(exception_wrapper ew);
 
 /** Make a Future from an exception type E that can be passed to
-  std::make_exception_ptr(). */
+  std::make_exception_ptr().
+
+  NOTE: This function is deprecated. Please use makeSemiFuture and pass the
+       appropriate executor to .via on the returned SemiFuture to get a
+       valid Future where necessary.
+ */
 template <class T, class E>
 typename std::enable_if<std::is_base_of<std::exception, E>::value,
                         Future<T>>::type
 makeFuture(E const& e);
 
-/** Make a Future out of a Try */
+/**
+  Make a Future out of a Try
+
+  NOTE: This function is deprecated. Please use makeSemiFuture and pass the
+       appropriate executor to .via on the returned SemiFuture to get a
+       valid Future where necessary.
+ */
 template <class T>
 Future<T> makeFuture(Try<T>&& t);