|
proxygen
|
#include <Future.h>
Public Types | |
| typedef T | value_type |
Public Member Functions | |
| template<class T2 = T, typename = typename std::enable_if< !isFuture<typename std::decay<T2>::type>::value && !isSemiFuture<typename std::decay<T2>::type>::value>::type> | |
| FutureBase (T2 &&val) | |
| template<class T2 = T> | |
| FutureBase (typename std::enable_if< std::is_same< Unit, T2 >::value >::type *) | |
| template<class... Args, typename std::enable_if< std::is_constructible< T, Args &&... >::value, int >::type = 0> | |
| FutureBase (in_place_t, Args &&...args) | |
| FutureBase (FutureBase< T > const &)=delete | |
| FutureBase (SemiFuture< T > &&) noexcept | |
| FutureBase (Future< T > &&) noexcept | |
| FutureBase (Future< T > const &)=delete | |
| FutureBase (SemiFuture< T > const &)=delete | |
| ~FutureBase () | |
| bool | valid () const noexcept |
| T & | value ()& |
| T const & | value () const & |
| T && | value ()&& |
| T const && | value () const && |
| Try< T > & | result ()& |
| Try< T > const & | result () const & |
| Try< T > && | result ()&& |
| Try< T > const && | result () const && |
| bool | isReady () const |
| bool | hasValue () const |
| bool | hasException () const |
| Optional< Try< T > > | poll () |
| template<class F > | |
| void | setCallback_ (F &&func) |
| template<class F > | |
| void | setCallback_ (F &&func, std::shared_ptr< folly::RequestContext > context) |
| void | raise (exception_wrapper interrupt) |
| template<class E > | |
| void | raise (E &&exception) |
| void | cancel () |
| int8_t | getPriority () const |
Protected Types | |
| using | Core = futures::detail::Core< T > |
Protected Member Functions | |
| Core & | getCore () |
| Core const & | getCore () const |
| Try< T > & | getCoreTryChecked () |
| Try< T > const & | getCoreTryChecked () const |
| FutureBase (Core *obj) | |
| FutureBase (futures::detail::EmptyConstruct) noexcept | |
| void | detach () |
| void | throwIfInvalid () const |
| void | throwIfContinued () const |
| void | assign (FutureBase< T > &&other) noexcept |
| Executor * | getExecutor () const |
| void | setExecutor (Executor *x, int8_t priority=Executor::MID_PRI) |
| void | setExecutor (Executor::KeepAlive<> x, int8_t priority=Executor::MID_PRI) |
| template<typename F , typename R > | |
| std::enable_if<!R::ReturnsFuture::value, typename R::Return >::type | thenImplementation (F &&func, R) |
| template<typename F , typename R > | |
| std::enable_if< R::ReturnsFuture::value, typename R::Return >::type | thenImplementation (F &&func, R) |
| template<typename E > | |
| SemiFuture< T > | withinImplementation (Duration dur, E e, Timekeeper *tk)&& |
Static Protected Member Functions | |
| template<typename Self > | |
| static decltype(auto) | getCoreImpl (Self &self) |
| template<typename Self > | |
| static decltype(auto) | getCoreTryChecked (Self &self) |
Protected Attributes | |
| Core * | core_ |
Friends | |
| class | Promise< T > |
| template<class > | |
| class | SemiFuture |
| template<class > | |
| class | Future |
|
protected |
| typedef T folly::futures::detail::FutureBase< T >::value_type |
| folly::futures::detail::FutureBase< T >::FutureBase | ( | T2 && | val | ) |
Construct from a value (perfect forwarding)
Postconditions:
valid() == trueisReady() == truehasValue() == true Definition at line 149 of file Future-inl.h.
| folly::futures::detail::FutureBase< T >::FutureBase | ( | typename std::enable_if< std::is_same< Unit, T2 >::value >::type * | ) |
Construct a (logical) FutureBase-of-void.
Postconditions:
valid() == trueisReady() == truehasValue() == true Definition at line 154 of file Future-inl.h.
References testing::Args(), folly::T, type, and folly::futures::detail::FutureBase< T >::value().
|
explicit |
Definition at line 163 of file Future-inl.h.
|
delete |
|
noexcept |
Definition at line 138 of file Future-inl.h.
|
noexcept |
Definition at line 143 of file Future-inl.h.
|
delete |
|
delete |
| folly::futures::detail::FutureBase< T >::~FutureBase | ( | ) |
Definition at line 173 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::detach().
|
inlineexplicitprotected |
|
explicitprotectednoexcept |
Definition at line 274 of file Future-inl.h.
|
protectednoexcept |
Definition at line 167 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::core_, folly::futures::detail::FutureBase< T >::detach(), and folly::exchange().
Referenced by folly::SemiFuture< T >::operator=(), and folly::Future< T >::operator=().
|
inline |
Raises a FutureCancellation interrupt. See raise(exception_wrapper) for details.
|
protected |
Definition at line 233 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::core_, and folly::futures::detail::Core< T >::detachFuture().
Referenced by folly::futures::detail::FutureBase< T >::assign(), folly::SemiFuture< T >::releaseDeferredExecutor(), folly::SemiFuture< T >::wait(), and folly::futures::detail::FutureBase< T >::~FutureBase().
|
inlineprotected |
Definition at line 366 of file Future.h.
Referenced by folly::futures::detail::chainExecutor(), folly::futures::detail::FutureBase< T >::isReady(), folly::Future< T >::onError(), folly::futures::detail::FutureBase< T >::poll(), folly::futures::detail::FutureBase< T >::raise(), folly::futures::detail::FutureBase< T >::setCallback_(), and folly::futures::detail::FutureBase< T >::thenImplementation().
|
inlineprotected |
Definition at line 369 of file Future.h.
|
inlinestaticprotected |
|
inlineprotected |
Definition at line 381 of file Future.h.
Referenced by folly::futures::detail::FutureBase< T >::result().
|
inlineprotected |
Definition at line 384 of file Future.h.
|
inlinestaticprotected |
|
inlineprotected |
Definition at line 412 of file Future.h.
Referenced by folly::futures::detail::chainExecutor(), folly::futures::detail::convertFuture(), folly::Future< T >::delayed(), folly::SemiFuture< T >::getDeferredExecutor(), folly::FutureSplitter< T >::getExecutorFrom(), folly::SemiFuture< T >::stealDeferredExecutor(), folly::Future< T >::thenError(), folly::futures::detail::FutureBase< T >::thenImplementation(), and folly::Future< T >::within().
|
inline |
| bool folly::futures::detail::FutureBase< T >::hasException | ( | ) | const |
True if the result is an exception (not a value) on a future for which isReady returns true.
Equivalent to result().hasException()
Preconditions:
valid() == true (else throws FutureInvalid)isReady() == true (else throws FutureNotReady) Definition at line 228 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::result().
| bool folly::futures::detail::FutureBase< T >::hasValue | ( | ) | const |
True if the result is a value (not an exception) on a future for which isReady returns true.
Equivalent to result().hasValue()
Preconditions:
valid() == true (else throws FutureInvalid)isReady() == true (else throws FutureNotReady) Definition at line 223 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::result().
Referenced by fizz::server::test::ServerProtocolTest::getActions(), and folly::Future< T >::willEqual().
| bool folly::futures::detail::FutureBase< T >::isReady | ( | ) | const |
True when the result (or exception) is ready; see value(), result(), etc.
Preconditions:
valid() == true (else throws FutureInvalid) Definition at line 218 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::getCore(), and folly::futures::detail::Core< T >::hasResult().
Referenced by folly::Future< T >::getTryVia(), folly::Future< T >::getVia(), folly::makePromiseContract(), TEST(), folly::futures::detail::waitViaImpl(), and folly::Future< T >::within().
| Optional< Try< T > > folly::futures::detail::FutureBase< T >::poll | ( | ) |
Returns either an Optional holding the result or an empty Optional depending on whether or not (respectively) the promise has been fulfilled (i.e., isReady() == true).
Preconditions:
valid() == true (else throws FutureInvalid)Postconditions:
valid() == true (note however that this moves-out the result when it returns a populated Try<T>, which effects any subsequent use of that result, e.g., poll(), result(), value(), get(), etc.) Definition at line 255 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::getCore(), and folly::gen::move.
| void folly::futures::detail::FutureBase< T >::raise | ( | exception_wrapper | interrupt | ) |
Provides a threadsafe back-channel so the consumer's thread can send an interrupt-object to the producer's thread.
If the promise-holder registers an interrupt-handler and consumer thread raises an interrupt early enough (details below), the promise-holder will typically halt its work, fulfilling the future with an exception or some special non-exception value.
However this interrupt request is voluntary, asynchronous, & advisory:
Promise object and registers an interrupt-handler; see Promise::setInterruptHandler().raise() is called before (or possibly shortly after) the producer is done producing its result, which is asynchronous with respect to the call to raise().Guidelines:
Preconditions:
valid() == true (else throws FutureInvalid)Postconditions:
raise() was previously called on this or any other Future/SemiFuture that uses the same shared state as this.exception_wrapper).The specific thread used to invoke the producer's interrupt-handler (if it is called at all) depends on timing:
raise() (or possibly concurrently within the call to raise()), the interrupt-handler will be executed using this current thread within the call to raise().raise() (and possibly concurrently within the call to raise()), the interrupt-handler will be executed using the producer's thread within the call to Promise::setInterruptHandler().Synchronizes between raise() (in the consumer's thread) and Promise::setInterruptHandler() (in the producer's thread).
Definition at line 262 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::getCore(), folly::gen::move, and folly::futures::detail::Core< T >::raise().
|
inline |
Raises the specified exception-interrupt. See raise(exception_wrapper) for details.
Definition at line 336 of file Future.h.
References type.
| Try< T > && folly::futures::detail::FutureBase< T >::result | ( | ) |
Returns a reference to the result's Try if it is ready, with a reference category and const-qualification like those of the future.
Does not wait(); see get() for that.
Preconditions:
valid() == true (else throws FutureInvalid)isReady() == true (else throws FutureNotReady)Postconditions:
& or the && overloads or via casts. Definition at line 198 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::getCoreTryChecked().
Referenced by folly::collect(), folly::collectN(), folly::Future< T >::getTry(), folly::Future< T >::getTryVia(), folly::futures::detail::FutureBase< T >::hasException(), folly::futures::detail::FutureBase< T >::hasValue(), folly::futures::detail::FutureBase< T >::result(), and folly::futures::detail::FutureBase< T >::value().
| Try< T > const && folly::futures::detail::FutureBase< T >::result | ( | ) | const |
Definition at line 203 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::getCoreTryChecked(), folly::gen::move, and folly::futures::detail::FutureBase< T >::result().
| Try<T>&& folly::futures::detail::FutureBase< T >::result | ( | ) |
| Try<T> const&& folly::futures::detail::FutureBase< T >::result | ( | ) | const |
| void folly::futures::detail::FutureBase< T >::setCallback_ | ( | F && | func | ) |
This is not the method you're looking for.
This needs to be public because it's used by make* and when*, and it's not worth listing all those and their fancy template signatures as friends. But it's not for public consumption.
Definition at line 268 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::getCore(), folly::RequestContext::saveContext(), folly::futures::detail::Core< T >::setCallback(), and folly::futures::detail::FutureBase< T >::throwIfContinued().
Referenced by folly::futures::detail::chainExecutor(), folly::collectN(), folly::Future< T >::onError(), folly::Future< T >::onTimeout(), folly::futures::detail::FutureBase< T >::thenImplementation(), and folly::SemiFuture< T >::wait().
| void folly::futures::detail::FutureBase< T >::setCallback_ | ( | F && | func, |
| std::shared_ptr< folly::RequestContext > | context | ||
| ) |
|
inlineprotected |
Definition at line 420 of file Future.h.
Referenced by folly::SemiFuture< T >::defer(), folly::SemiFuture< T >::operator=(), folly::SemiFuture< T >::SemiFuture(), and folly::Future< T >::via().
|
inlineprotected |
Definition at line 424 of file Future.h.
References folly::futures::detail::convertFuture(), f, folly::futures::detail::getDeferredExecutor(), folly::gen::move, folly::futures::detail::stealDeferredExecutor(), and type.
|
protected |
Definition at line 311 of file Future-inl.h.
References B, folly::futures::detail::FutureBase< T >::core_, folly::Promise< T >::core_, f, folly::futures::detail::FutureBase< T >::getCore(), folly::futures::detail::FutureBase< T >::getExecutor(), folly::Promise< T >::getSemiFuture(), folly::futures::detail::detail_msvc_15_7_workaround::invoke(), folly::futures::detail::makeCoreCallbackState(), folly::makeTryWith(), folly::gen::move, folly::futures::detail::FutureBase< T >::setCallback_(), folly::pushmi::detail::t, and value.
Referenced by folly::futures::detail::chainExecutor(), folly::Future< T >::thenTry(), folly::Future< T >::thenValue(), folly::Future< T >::via(), and folly::futures::detail::FutureBase< T >::withinImplementation().
|
protected |
|
protected |
Definition at line 248 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::core_, and folly::futures::detail::Core< T >::hasCallback().
Referenced by folly::futures::detail::FutureBase< T >::setCallback_().
|
protected |
Definition at line 241 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::core_.
Referenced by folly::Future< T >::via().
|
inlinenoexcept |
true if this has a shared state; false if this has been either moved-out or created without a shared state.
Definition at line 162 of file Future.h.
References context, folly::netops::poll(), and folly::value().
| T && folly::futures::detail::FutureBase< T >::value | ( | ) |
Returns a reference to the result value if it is ready, with a reference category and const-qualification like those of the future.
Does not wait(); see get() for that.
Preconditions:
valid() == true (else throws FutureInvalid)isReady() == true (else throws FutureNotReady)Postconditions:
hasException() == true), throws that exception.& or the && overloads or via casts. Definition at line 178 of file Future-inl.h.
References folly::futures::detail::FutureBase< T >::result().
Referenced by BENCHMARK_RELATIVE(), folly::collectN(), folly::Future< T >::Future(), folly::futures::detail::FutureBase< T >::FutureBase(), folly::Future< T >::getVia(), folly::makeFuture(), folly::makeFutureWith(), folly::makeSemiFuture(), folly::makeSemiFutureWith(), folly::Future< T >::onError(), folly::Future< T >::onTimeout(), folly::Future< T >::operator=(), folly::reduce(), TEST(), folly::futures::detail::FutureBase< T >::value(), and folly::futures::detail::waitImpl().
| T const && folly::futures::detail::FutureBase< T >::value | ( | ) | const |
Definition at line 183 of file Future-inl.h.
References folly::gen::move, folly::futures::detail::FutureBase< T >::result(), and folly::futures::detail::FutureBase< T >::value().
| T&& folly::futures::detail::FutureBase< T >::value | ( | ) |
| T const&& folly::futures::detail::FutureBase< T >::value | ( | ) | const |
|
protected |
Definition at line 430 of file Future-inl.h.
References f, folly::detail::getTimekeeperSingleton(), LIKELY, folly::gen::move, folly::pushmi::detail::t, folly::futures::detail::FutureBase< T >::thenImplementation(), folly::to_weak_ptr(), and UNLIKELY.
|
protected |
Definition at line 399 of file Future.h.
Referenced by folly::futures::detail::FutureBase< T >::assign(), folly::futures::detail::chainExecutor(), folly::SemiFuture< T >::defer(), folly::futures::detail::FutureBase< T >::detach(), folly::SemiFuture< T >::getTry(), folly::SemiFuture< T >::operator=(), folly::SemiFuture< T >::SemiFuture(), folly::SemiFuture< T >::stealDeferredExecutor(), folly::futures::detail::FutureBase< T >::thenImplementation(), folly::futures::detail::FutureBase< T >::throwIfContinued(), folly::futures::detail::FutureBase< T >::throwIfInvalid(), folly::SemiFuture< T >::via(), folly::Future< T >::via(), and folly::SemiFuture< T >::~SemiFuture().