Pigweed
 
Loading...
Searching...
No Matches
pw::async2::PendableAsTask< Pendable > Class Template Reference

#include <pendable_as_task.h>

Inheritance diagram for pw::async2::PendableAsTask< Pendable >:
pw::async2::Task

Public Member Functions

 PendableAsTask (Pendable &&pendable)
 
Pendable & operator* ()
 
Pendable * operator-> ()
 
- Public Member Functions inherited from pw::async2::Task
 Task (const Task &)=delete
 
 Task (Task &&)=delete
 
Taskoperator= (const Task &)=delete
 
Taskoperator= (Task &&)=delete
 
Poll Pend (Context &cx)
 
bool IsRegistered () const
 
void Deregister ()
 
void Destroy ()
 

Private Member Functions

Poll DoPend (Context &cx) final
 

Detailed Description

template<typename Pendable>
class pw::async2::PendableAsTask< Pendable >

A Task that delegates to a type with a Pend method.

The wrapped type must have a Pend method which accepts a Context& and return a Poll<>.

If Pendable is a pointer, PendableAsTask will dereference it and attempt to invoke Pend.

Constructor & Destructor Documentation

◆ PendableAsTask()

template<typename Pendable >
pw::async2::PendableAsTask< Pendable >::PendableAsTask ( Pendable &&  pendable)
inline

Create a new Task which delegates Pend to pendable.

See class docs for more details.

Member Function Documentation

◆ DoPend()

template<typename Pendable >
Poll pw::async2::PendableAsTask< Pendable >::DoPend ( Context )
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.


The documentation for this class was generated from the following file: