Pigweed
 
Loading...
Searching...
No Matches
pw::async2::Dispatcher Class Reference

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

#include <dispatcher.h>

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.
 
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

◆ 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.


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