proxygen
|
#include <Promise.h>
Public Types | |
typedef T | value_type |
typedef BatonT | baton_type |
Public Member Functions | |
~Promise () | |
Promise (const Promise &)=delete | |
Promise & | operator= (const Promise &)=delete |
Promise (Promise &&) noexcept | |
Promise & | operator= (Promise &&) |
void | setValue () |
template<class M > | |
void | setValue (M &&value) |
void | setTry (folly::Try< T > &&t) |
template<class F > | |
void | setWith (F &&func) |
void | setException (folly::exception_wrapper) |
Static Public Member Functions | |
template<class F > | |
static value_type | await (F &&func) |
Private Member Functions | |
Promise (folly::Try< T > &value, BatonT &baton) | |
void | throwIfFulfilled () const |
template<class F > | |
std::enable_if< std::is_convertible< invoke_result_t< F >, T >::value &&!std::is_same< T, void >::value >::type | fulfilHelper (F &&func) |
template<class F > | |
std::enable_if< std::is_same< invoke_result_t< F >, void >::value &&std::is_same< T, void >::value >::type | fulfilHelper (F &&func) |
Private Attributes | |
folly::Try< T > * | value_ |
BatonT * | baton_ |
typedef BatonT folly::fibers::Promise< T, BatonT >::baton_type |
typedef T folly::fibers::Promise< T, BatonT >::value_type |
folly::fibers::Promise< T, BatonT >::~Promise | ( | ) |
Definition at line 47 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::setException(), and folly::fibers::Promise< T, BatonT >::value_.
|
delete |
|
noexcept |
Definition at line 26 of file Promise-inl.h.
|
private |
Definition at line 22 of file Promise-inl.h.
|
static |
Blocks task execution until given promise is fulfilled.
Calls function passing in a Promise<T>, which has to be fulfilled.
Definition at line 94 of file Promise-inl.h.
References folly::gen::move, and UNLIKELY.
Referenced by folly::fibers::await().
|
private |
|
private |
|
delete |
Promise< T, BatonT > & folly::fibers::Promise< T, BatonT >::operator= | ( | Promise< T, BatonT > && | other | ) |
Definition at line 33 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::baton_, folly::f14::swap(), and folly::fibers::Promise< T, BatonT >::value_.
void folly::fibers::Promise< T, BatonT >::setException | ( | folly::exception_wrapper | e | ) |
Fulfill the Promise with an exception_wrapper, e.g. auto ew = folly::try_and_catch<std::exception>([]{ ... }); if (ew) { p.setException(std::move(ew)); }
Definition at line 55 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::setTry().
Referenced by folly::fibers::Promise< T, BatonT >::~Promise().
void folly::fibers::Promise< T, BatonT >::setTry | ( | folly::Try< T > && | t | ) |
Fulfill the promise with a given try
t |
Definition at line 60 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::baton_, folly::gen::move, folly::pushmi::detail::t, folly::fibers::Promise< T, BatonT >::throwIfFulfilled(), and folly::fibers::Promise< T, BatonT >::value_.
Referenced by folly::fibers::Promise< T, BatonT >::setException(), folly::fibers::Promise< T, BatonT >::setValue(), and folly::fibers::Promise< T, BatonT >::setWith().
void folly::fibers::Promise< T, BatonT >::setValue | ( | ) |
Fulfill this promise (only for Promise<void>)
Definition at line 80 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::setTry(), and value.
Referenced by TEST().
void folly::fibers::Promise< T, BatonT >::setValue | ( | M && | value | ) |
Set the value (use perfect forwarding for both move and copy)
Definition at line 73 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::setTry(), and value.
void folly::fibers::Promise< T, BatonT >::setWith | ( | F && | func | ) |
Fulfill this promise with the result of a function that takes no arguments and returns something implicitly convertible to T. Captures exceptions. e.g.
p.setWith([] { do something that may throw; return a T; });
Definition at line 88 of file Promise-inl.h.
References folly::makeTryWith(), and folly::fibers::Promise< T, BatonT >::setTry().
|
private |
Definition at line 40 of file Promise-inl.h.
References folly::fibers::Promise< T, BatonT >::value_.
Referenced by folly::fibers::Promise< T, BatonT >::setTry().
|
private |
Definition at line 87 of file Promise.h.
Referenced by folly::fibers::Promise< T, BatonT >::operator=(), and folly::fibers::Promise< T, BatonT >::setTry().
|
private |
Definition at line 86 of file Promise.h.
Referenced by folly::fibers::Promise< T, BatonT >::operator=(), folly::fibers::Promise< T, BatonT >::setTry(), folly::fibers::Promise< T, BatonT >::throwIfFulfilled(), and folly::fibers::Promise< T, BatonT >::~Promise().