proxygen
|
#include <SharedPromise.h>
Public Member Functions | |
SharedPromise ()=default | |
~SharedPromise ()=default | |
SharedPromise (SharedPromise const &)=delete | |
SharedPromise & | operator= (SharedPromise const &)=delete |
SharedPromise (SharedPromise< T > &&) noexcept | |
SharedPromise & | operator= (SharedPromise< T > &&) noexcept |
SemiFuture< T > | getSemiFuture () |
Future< T > | getFuture () |
size_t | size () |
void | setException (exception_wrapper ew) |
template<class E > | |
std::enable_if< std::is_base_of< std::exception, E >::value >::type | setException (E const &) |
void | setInterruptHandler (std::function< void(exception_wrapper const &)>) |
template<class B = T> | |
std::enable_if< std::is_same< Unit, B >::value, void >::type | setValue () |
Sugar to fulfill this SharedPromise<Unit> More... | |
template<class M > | |
void | setValue (M &&value) |
void | setTry (Try< T > &&t) |
template<class F > | |
void | setWith (F &&func) |
bool | isFulfilled () |
Private Attributes | |
std::mutex | mutex_ |
size_t | size_ {0} |
bool | hasValue_ {false} |
Try< T > | try_ |
std::vector< Promise< T > > | promises_ |
std::function< void(exception_wrapper const &)> | interruptHandler_ |
Definition at line 41 of file SharedPromise.h.
|
default |
|
default |
|
delete |
|
noexcept |
Future< T > folly::SharedPromise< T >::getFuture | ( | ) |
Return a Future tied to the shared core state. Unlike Promise::getFuture, this can be called an unlimited number of times per SharedPromise. NOTE: This function is deprecated. Please use getSemiFuture and pass the appropriate executor to .via on the returned SemiFuture to get a valid Future where necessary.
Definition at line 72 of file SharedPromise-inl.h.
References folly::InlineExecutor::instance(), type, and value.
Referenced by TEST(), and wangle::OutputBufferingHandler::write().
SemiFuture< T > folly::SharedPromise< T >::getSemiFuture | ( | ) |
Return a Future tied to the shared core state. Unlike Promise::getFuture, this can be called an unlimited number of times per SharedPromise.
Definition at line 57 of file SharedPromise-inl.h.
Referenced by TEST().
bool folly::SharedPromise< T >::isFulfilled | ( | ) |
Definition at line 133 of file SharedPromise-inl.h.
Referenced by folly::SharedPromise< folly::folly::Unit >::setValue(), and TEST().
|
delete |
|
noexcept |
Definition at line 27 of file SharedPromise-inl.h.
References folly::detail::lock(), mutex_, and folly::f14::swap().
void folly::SharedPromise< T >::setException | ( | exception_wrapper | ew | ) |
Fulfill the SharedPromise with an exception_wrapper
Definition at line 84 of file SharedPromise-inl.h.
References folly::gen::move.
Referenced by wangle::OutputBufferingHandler::close().
std::enable_if< std::is_base_of< std::exception, E >::value >::type folly::SharedPromise< T >::setException | ( | E const & | e | ) |
Fulfill the SharedPromise with an exception type E, which can be passed to make_exception_wrapper(). Useful for originating exceptions. If you caught an exception the exception_wrapper form is more appropriate.
Definition at line 79 of file SharedPromise-inl.h.
void folly::SharedPromise< T >::setInterruptHandler | ( | std::function< void(exception_wrapper const &)> | fn | ) |
Set an interrupt handler to handle interrupts. See the documentation for Future::raise(). Your handler can do whatever it wants, but if you bother to set one then you probably will want to fulfill the SharedPromise with an exception (or special value) indicating how the interrupt was handled.
Definition at line 89 of file SharedPromise-inl.h.
Referenced by TEST().
void folly::SharedPromise< T >::setTry | ( | Try< T > && | t | ) |
Definition at line 114 of file SharedPromise-inl.h.
References g(), folly::gen::move, mutex_, and folly::pushmi::detail::t.
Referenced by wangle::OutputBufferingHandler::runLoopCallback(), and folly::SharedPromise< folly::folly::Unit >::setValue().
|
inline |
Sugar to fulfill this SharedPromise<Unit>
Definition at line 92 of file SharedPromise.h.
Referenced by folly::SharedPromise< folly::folly::Unit >::setValue(), and TEST().
Set the value (use perfect forwarding for both move and copy)
Definition at line 103 of file SharedPromise-inl.h.
Fulfill this SharedPromise 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 109 of file SharedPromise-inl.h.
References folly::makeTryWith().
Referenced by folly::SharedPromise< folly::folly::Unit >::setValue(), and TEST().
size_t folly::SharedPromise< T >::size | ( | ) |
Return the number of Futures associated with this SharedPromise
Definition at line 51 of file SharedPromise-inl.h.
|
private |
Definition at line 116 of file SharedPromise.h.
|
private |
Definition at line 119 of file SharedPromise.h.
|
private |
Definition at line 114 of file SharedPromise.h.
|
private |
Definition at line 118 of file SharedPromise.h.
|
private |
Definition at line 115 of file SharedPromise.h.
|
private |
Definition at line 117 of file SharedPromise.h.