#pragma once
+#include <folly/wangle/Deprecated.h>
#include <folly/wangle/Executor.h>
#include <folly/wangle/Future.h>
#include <folly/Optional.h>
* .then([=]Try<DiskResponse>&& t) { return sendClientResponse(t.value()); })
* .launch();
*/
+// DEPRECATED. Just use Future::via() to accomplish the same thing. If it's
+// not obvious how, feel free to reach out.
template <class T>
-class Later {
+class DEPRECATED Later {
public:
typedef T value_type;
Later<typename std::result_of<F(Try<T>&&)>::type::value_type> >::type
then(F&& fn);
+
+ /// Variant where func is an ordinary function (static method, method)
+ /// Must return a Later
+ template <class R>
+ typename std::enable_if<isLater<R>::value, R>::type
+ inline then(R(*func)(Try<T>&&)) {
+ return then([func](Try<T>&& t) {
+ return (*func)(std::move(t));
+ });
+ }
+
+ /// Variant where func is an member function
+ /// Must return a Later
+ template <class R, class Caller>
+ typename std::enable_if<isLater<R>::value, R>::type
+ inline then(Caller *instance, R(Caller::*func)(Try<T>&&)) {
+ return then([instance, func](Try<T>&& t) {
+ return (instance->*func)(std::move(t));
+ });
+ }
+
/*
* Resets the executor - all then() calls made after the call to via() will be
* made in the new executor. The Executor must outlive.
*/
Future<T> launch();
- /*
- * Deprecated. Use launch()
- */
- void fireAndForget() __attribute__ ((deprecated)) { launch(); }
-
private:
Promise<void> starter_;
folly::Optional<Future<T>> future_;
friend class Later;
};
+// See Future.whenAll
+template <class T>
+Later<std::vector<Try<T>>> whenAllLater(std::vector<Later<T>>&& laters);
+
}}
-#include "Later-inl.h"
+#include <folly/wangle/Later-inl.h>