proxygen
folly::FutureExecutor< ExecutorImpl > Class Template Reference

#include <FutureExecutor.h>

Inheritance diagram for folly::FutureExecutor< ExecutorImpl >:

Public Member Functions

template<typename... Args>
 FutureExecutor (Args &&...args)
 
template<typename F >
std::enable_if< folly::isFuture< invoke_result_t< F > >::value, invoke_result_t< F > >::type addFuture (F func)
 
template<typename F >
std::enable_if< !folly::isFuture< invoke_result_t< F > >::value, folly::Future< typename folly::lift_unit< invoke_result_t< F > >::type > >::type addFuture (F func)
 

Detailed Description

template<typename ExecutorImpl>
class folly::FutureExecutor< ExecutorImpl >

Definition at line 25 of file FutureExecutor.h.

Constructor & Destructor Documentation

template<typename ExecutorImpl>
template<typename... Args>
folly::FutureExecutor< ExecutorImpl >::FutureExecutor ( Args &&...  args)
inlineexplicit

Definition at line 28 of file FutureExecutor.h.

References type, and folly::value().

29  : ExecutorImpl(std::forward<Args>(args)...) {}

Member Function Documentation

template<typename ExecutorImpl>
template<typename F >
std::enable_if< folly::isFuture<invoke_result_t<F> >::value, invoke_result_t<F> >::type folly::FutureExecutor< ExecutorImpl >::addFuture ( func)
inline

Definition at line 44 of file FutureExecutor.h.

References add, folly::Promise< T >::getFuture(), folly::gen::move, folly::Promise< T >::setTry(), folly::pushmi::detail::t, folly::T, type, and folly::value().

Referenced by futureExecutor().

44  {
45  using T = typename invoke_result_t<F>::value_type;
46  folly::Promise<T> promise;
47  auto future = promise.getFuture();
48  ExecutorImpl::add([promise = std::move(promise),
49  func = std::move(func)]() mutable {
50  func().then([promise = std::move(promise)](folly::Try<T>&& t) mutable {
51  promise.setTry(std::move(t));
52  });
53  });
54  return future;
55  }
auto add
Definition: BaseTest.cpp:70
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::std T
void setTry(Try< T > &&t)
Definition: Promise-inl.h:122
Future< T > getFuture()
Definition: Promise-inl.h:97
Definition: Try.h:51
template<typename ExecutorImpl>
template<typename F >
std::enable_if< !folly::isFuture<invoke_result_t<F> >::value, folly::Future<typename folly::lift_unit<invoke_result_t<F> >::type> >::type folly::FutureExecutor< ExecutorImpl >::addFuture ( func)
inline

Definition at line 69 of file FutureExecutor.h.

References add, folly::Promise< T >::getFuture(), folly::gen::move, folly::Promise< T >::setWith(), folly::T, and type.

69  {
71  folly::Promise<T> promise;
72  auto future = promise.getFuture();
74  [promise = std::move(promise), func = std::move(func)]() mutable {
75  promise.setWith(std::move(func));
76  });
77  return future;
78  }
auto add
Definition: BaseTest.cpp:70
PskType type
void setWith(F &&func)
Definition: Promise-inl.h:137
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::std T
Future< T > getFuture()
Definition: Promise-inl.h:97

The documentation for this class was generated from the following file: