A Task that delegates to a provided function func.
The provided func may be any callable (function, lambda, or similar) which accepts a Context& and returns a Poll<>.
The resulting Task will implement Pend by invoking func.
Public Types | |
| using | CallableType = Func |
Public Member Functions | |
| PendFuncTask (Func &&func) | |
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 |
| Poll | Pend (Context &cx) |
| bool | IsRegistered () const |
| void | Deregister () |
| void | Destroy () |
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 which delegates Pend to func.
See class docs for more details.
|
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.
Task s 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.