FutureCore provides common functionality for futures that need to be wakeable and stored in a list.
This class provides the core mechanism for:
Waker to be woken up.IntrusiveList.It is designed to be used as a member of a concrete future class (composition) rather than a base class, to simplify move semantics and object lifetime.
Public Member Functions | |
| FutureCore (FutureCore &&other) noexcept | |
| FutureCore & | operator= (FutureCore &&other) noexcept |
| constexpr | FutureCore (FutureState::Pending) |
| constexpr | FutureCore (FutureState::ReadyForCompletion) |
| FutureCore (const FutureCore &)=delete | |
| FutureCore & | operator= (const FutureCore &)=delete |
| constexpr bool | is_pendable () const |
| constexpr bool | is_complete () const |
| constexpr bool | is_ready () const |
| constexpr bool | is_initialized () const |
| void | Wake () |
| void | WakeAndMarkReady () |
| Waker & | waker () |
| void | MarkComplete () |
| void | Unlist () |
| Removes this future from its list, if it is in one. | |
| void | Reset () |
Unlists the FutureCore and resets it to the empty state. | |
| template<typename FutureType > | |
| auto | DoPend (FutureType &future, Context &cx) |
| bool | in_list () const |
Friends | |
| class | BaseFutureList |
Additional Inherited Members | |
Protected Member Functions inherited from pw::IntrusiveForwardList< T >::Item | |
| constexpr | Item ()=default |
|
inlineexplicitconstexpr |
Constructs a pending FutureCore that represents an async operation. Pend must be called until it returns Ready.
A pending FutureCore must be tracked by its provider (e.g. in a FutureList).
|
inlineexplicitconstexpr |
Creates a wakeable future that is ready for completion. The next call to Pend must return Ready.
|
inline |
Optional Pend() function that defers to the future implementation's DoPend(Context&) function. FutureCore::DoPend does the following:
DoPend returns Pending, stores a waker.DoPend returns Ready, marks the future as complete.It is recommended for Pend to use FutureCore::DoPend, but not required. Custom Pend implementations must enforce the same semantics.
|
inline |
|
inlineconstexpr |
Pend() returned Ready.
|
inlineconstexpr |
true if the future was NOT default constructed. The future either represents an active or completed asynchronous operation.
|
inlineconstexpr |
Pend() function can be called.
|
inlineconstexpr |
true if the next Pend() call is guaranteed to return Ready. Depending on the implementation, Pend() may return Ready while is_ready is false.Future implementations call WakeAndMarkReady to set is_ready to true.
|
inline |
Mark the future as complete, which indicates that a future has returned Ready from its Pend function.
FutureCore::DoPend is used. FutureCore::DoPend calls MarkComplete when Pend() returns Ready.
|
inline |
Wakes the task waiting on the future, if any. The future must be pended in order to make progress.
|
inline |
Wakes the task pending the future and sets is_ready to true. Only call this if the next call to to the future's Pend() will return Ready.
|
inline |
Provides direct access to the waker for future implementations that manually store a waker.
FutureCore::DoPend is used. FutureCore::DoPend stores the waker when Pend() returns Pending.