#include <functional>
#include <memory>
#include <type_traits>
+#include <vector>
#include "folly/MoveWrapper.h"
#include "Promise.h"
typename std::add_lvalue_reference<const T>::type
value() const;
+ /// Returns a future which will call back on the other side of executor.
+ ///
+ /// f.via(e).then(a); // safe
+ ///
+ /// f.via(e).then(a).then(b); // faux pas
+ ///
+ /// a will definitely execute in the intended thread, but b may execute
+ /// either in that thread, or in the current thread. If you need to
+ /// guarantee where b executes, use a Later.
template <typename Executor>
- Future<T> executeWithSameThread(Executor* executor);
+ Future<T> via(Executor* executor);
+
+ /// Deprecated alias for via
+ template <typename Executor>
+ Future<T> executeWithSameThread(Executor* executor) {
+ return via(executor);
+ }
/**
Thread-safe version of executeWith
Instead, you may pass in a Promise so that we can set up
the rest of the chain in advance, without any racey
modifications of the continuation
+
+ Deprecated. Use a Later.
*/
template <typename Executor>
void executeWith(Executor* executor, Promise<T>&& cont_promise);
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 */
+template <class T>
+Future<T> makeFuture(Try<T>&& t);
+
/** When all the input Futures complete, the returned Future will complete.
Errors do not cause early termination; this Future will always succeed
after all its Futures have finished (whether successfully or with an
Try<typename std::iterator_traits<InputIterator>::value_type::value_type>>>>
whenN(InputIterator first, InputIterator last, size_t n);
+/** Wait for the given future to complete on a semaphore. Returns the result of
+ * the given future.
+ *
+ * NB if the promise for the future would be fulfilled in the same thread that
+ * you call this, it will deadlock.
+ */
+template <class F>
+typename F::value_type waitWithSemaphore(F&& f);
+
}} // folly::wangle
#include "Future-inl.h"