A Task that delegates to a provided Coro<T> and executes an error handler function if coroutine allocation fails.
Public Types | |
| using | value_type = std::conditional_t< std::is_void_v< T >, ReadyType, T > |
Public Member Functions | |
| template<typename ErrorHandler > | |
| FallibleCoroTask (Coro< T > &&coro, ErrorHandler &&error_handler) | |
| FallibleCoroTask (const FallibleCoroTask &)=delete | |
| FallibleCoroTask & | operator= (const FallibleCoroTask &)=delete |
| FallibleCoroTask (FallibleCoroTask &&)=delete | |
| FallibleCoroTask & | operator= (FallibleCoroTask &&)=delete |
| bool | ok () const |
| bool | has_value () const |
| value_type & | value () |
| const value_type & | value () const |
| std::optional< value_type > & | Wait () |
Public Member Functions inherited from pw::async2::Task | |
| constexpr | Task (log::Token name=kDefaultName) |
| Task (const Task &)=delete | |
| Task (Task &&)=delete | |
| Task & | operator= (const Task &)=delete |
| Task & | operator= (Task &&)=delete |
| virtual | ~Task () |
| Poll | Pend (Context &cx) |
| bool | IsRegistered () const |
| void | Deregister () |
| void | Join () |
Private Member Functions | |
| Poll | DoPend (Context &cx) final |
Additional Inherited Members | |
Protected Member Functions inherited from pw::containers::future::IntrusiveList< T >::Item | |
| constexpr | Item ()=default |
|
inline |
Create a new Task that runs coro, invoking or_else if allocation fails.
|
inlinefinalprivatevirtual |
Attempts to advance this Task to completion.
This method should not perform synchronous waiting, as doing so may block the main Dispatcher loop and prevent other Task s from progressing. Because of this, Task s should not invoke blocking Dispatcher methods such as RunUntilComplete.
Tasks should also avoid invoking RunUntilStalled on their own Dispatcher.
Returns Ready if complete, or Pending if the Task was not yet able to complete.
If Pending is returned, the Task must ensure it is woken up when it is able to make progress. To do this, Task::Pend must arrange for Waker::Wake to be called, either by storing a copy of the Waker away to be awoken by another system (such as an interrupt handler).
Implements pw::async2::Task.
|
inline |
Returns whether the task ran and set that value to the function's return value.
|
inline |
Returns whether this FallibleCoroTask wraps a valid Coro and can be pended. Pending a !ok() FallibleCoroTask calls the error handler.
This will be false if Coro allocation failed.
|
inline |
The return value from the coroutine.
Join to ensure it finished.
|
inline |
The return value from the coroutine.
Join to ensure it finished.
|
inline |
Blocks until the task completes and returns the return value in a std::optional. The std::optional is empty if coroutine allocation failed.