Pigweed
 
Loading...
Searching...
No Matches
pw::async2::NativeDispatcherBase Class Referenceabstract

#include <dispatcher_base.h>

Inheritance diagram for pw::async2::NativeDispatcherBase:
pw::async2::backend::NativeDispatcher

Classes

class  RunOneTaskResult
 
class  SleepInfo
 

Public Member Functions

 NativeDispatcherBase (NativeDispatcherBase &)=delete
 
 NativeDispatcherBase (NativeDispatcherBase &&)=delete
 
NativeDispatcherBaseoperator= (NativeDispatcherBase &)=delete
 
NativeDispatcherBaseoperator= (NativeDispatcherBase &&)=delete
 

Protected Member Functions

bool HasPostedTask (Task &task)
 Check that a task is posted on this Dispatcher.
 
void Deregister ()
 
void Post (Task &task)
 
SleepInfo AttemptRequestWake (bool allow_empty)
 
RunOneTaskResult RunOneTask (Dispatcher &dispatcher, Task *task_to_look_for)
 

Private Member Functions

virtual void DoWake ()=0
 

Friends

class Dispatcher
 
class Task
 
class Waker
 

Detailed Description

A base class used by Dispatcher implementations.

Note that only one Dispatcher implementation should exist per toolchain. However, a common base class is used in order to share behavior and standardize the interface of these Dispatcher s, and to prevent build system cycles due to Task needing to refer to the Dispatcher class.

Member Function Documentation

◆ AttemptRequestWake()

SleepInfo pw::async2::NativeDispatcherBase::AttemptRequestWake ( bool  allow_empty)
protected

Indicates that this Dispatcher is about to go to sleep and requests that it be awoken when more work is available in the future.

Dispatchers must invoke this method before sleeping in order to ensure that they receive a DoWake call when there is more work to do.

The returned SleepInfo will describe whether and for how long the Dispatcher implementation should go to sleep. Notably it will return that the Dispatcher should not sleep if there is still more work to be done.

Parameters
allow_emptyWhether or not to allow sleeping when no tasks are registered.

◆ Deregister()

void pw::async2::NativeDispatcherBase::Deregister ( )
protected

Removes references to this NativeDispatcherBase from all linked Task s and Waker s.

This must be called by Dispatcher implementations in their destructors. It is not called by the NativeDispatcherBase destructor, as doing so would allow the Dispatcher to be referenced between the calls to ~Dispatcher and ~NativeDispatcherBase.

◆ DoWake()

virtual void pw::async2::NativeDispatcherBase::DoWake ( )
privatepure virtual

Sends a wakeup signal to this Dispatcher.

This method's implementation should ensure that the Dispatcher comes back from sleep and begins invoking RunOneTask again.

Note: the dispatcher_lock() may or may not be held here, so it must not be acquired by DoWake, nor may DoWake assume that it has been acquired.

Implemented in pw::async2::backend::NativeDispatcher.

◆ RunOneTask()

RunOneTaskResult pw::async2::NativeDispatcherBase::RunOneTask ( Dispatcher dispatcher,
Task task_to_look_for 
)
protected

Attempts to run a single task, returning whether any tasks were run, and whether task_to_look_for was run.


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