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 | List of all members
pw::async2::Dispatcher Class Reference

A single-threaded cooperatively-scheduled runtime for async tasks. More...

Public Member Functions

 Dispatcher ()=default
 Constructs a new async Dispatcher.
 
 Dispatcher (Dispatcher &)=delete
 
 Dispatcher (Dispatcher &&)=delete
 
Dispatcheroperator= (Dispatcher &)=delete
 
Dispatcheroperator= (Dispatcher &&)=delete
 
void Post (Task &task)
 
Poll RunUntilStalled ()
 Runs tasks until none are able to make immediate progress.
 
Poll RunUntilStalled (Task &task)
 
template<typename Pendable >
Poll< PendOutputOf< Pendable > > RunPendableUntilStalled (Pendable &pendable)
 
void RunToCompletion ()
 Runs until all tasks complete.
 
void RunToCompletion (Task &task)
 Runs until task completes.
 
template<typename Pendable >
PendOutputOf< Pendable > RunPendableToCompletion (Pendable &pendable)
 Runs until pendable completes, returning the output of pendable.
 
void LogRegisteredTasks ()
 
uint32_t tasks_polled () const
 
uint32_t tasks_completed () const
 Returns the total number of tasks the dispatcher has run to completion.
 
pw::async2::backend::NativeDispatchernative ()
 Returns a reference to the native backend-specific dispatcher type.
 

Detailed Description

A single-threaded cooperatively-scheduled runtime for async tasks.

Member Function Documentation

◆ LogRegisteredTasks()

void pw::async2::Dispatcher::LogRegisteredTasks ( )
inline

Outputs log statements about the tasks currently registered with this dispatcher.

◆ Post()

void pw::async2::Dispatcher::Post ( Task task)
inline

Tells the Dispatcher to run Task to completion. This method does not block.

After Post is called, Task::Pend will be invoked once. If Task::Pend does not complete, the Dispatcher will wait until the Task is "awoken", at which point it will call Pend again until the Task completes.

This method is thread-safe and interrupt-safe.

◆ RunPendableUntilStalled()

template<typename Pendable >
Poll< PendOutputOf< Pendable > > pw::async2::Dispatcher::RunPendableUntilStalled ( Pendable &  pendable)
inline

Runs tasks until none are able to make immediate progress, or until pendable completes.

Returns a Poll containing the possible output of pendable.

◆ RunUntilStalled()

Poll pw::async2::Dispatcher::RunUntilStalled ( Task task)
inline

Runs tasks until none are able to make immediate progress, or until task completes.

Returns whether task completed.

◆ tasks_polled()

uint32_t pw::async2::Dispatcher::tasks_polled ( ) const
inline

Returns the total number of times the dispatcher has called a task's Pend() method.


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