Pigweed
C/C++ API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
pw::async2::CoroOrElseTask Class Reference
Inheritance diagram for pw::async2::CoroOrElseTask:
pw::async2::Task pw::containers::future::IntrusiveList< T >::Item

Public Member Functions

 CoroOrElseTask (Coro< Status > &&coro, pw::Function< void(Status)> &&or_else)
 
void SetCoro (Coro< Status > &&coro)
 
void SetErrorHandler (pw::Function< void(Status)> &&or_else)
 
- Public Member Functions inherited from pw::async2::Task
constexpr Task (log::Token name)
 
 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
 

Additional Inherited Members

- Protected Member Functions inherited from pw::containers::future::IntrusiveList< T >::Item
constexpr Item ()=default
 

Detailed Description

A Task that delegates to a provided Coro<Status>> and executes an or_else handler function on failure.

Constructor & Destructor Documentation

◆ CoroOrElseTask()

pw::async2::CoroOrElseTask::CoroOrElseTask ( Coro< Status > &&  coro,
pw::Function< void(Status)> &&  or_else 
)
inline

Create a new Task which runs coro, invoking or_else on any non-OK status.

Member Function Documentation

◆ DoPend()

Poll pw::async2::CoroOrElseTask::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.

◆ SetCoro()

void pw::async2::CoroOrElseTask::SetCoro ( Coro< Status > &&  coro)
inline

Non-atomically sets coro.

The task must not be Posted when coro is changed.

◆ SetErrorHandler()

void pw::async2::CoroOrElseTask::SetErrorHandler ( pw::Function< void(Status)> &&  or_else)
inline

Non-atomically sets or_else.

The task must not be Posted when or_else is changed.


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