Pigweed
 
Loading...
Searching...
No Matches
pw::async::BasicDispatcher Class Reference

BasicDispatcher is a generic implementation of Dispatcher. More...

#include <dispatcher.h>

Inheritance diagram for pw::async::BasicDispatcher:
pw::async::Dispatcher pw::chrono::VirtualClock< SystemClock >

Public Member Functions

void RunUntilIdle ()
 Execute all runnable tasks and return without waiting.
 
void RunUntil (chrono::SystemClock::time_point end_time)
 
void RunFor (chrono::SystemClock::duration duration)
 
void RequestStop ()
 
void Run () override
 
void PostAt (Task &task, chrono::SystemClock::time_point time) override
 
bool Cancel (Task &task) override
 
chrono::SystemClock::time_point now () override
 Returns the current time.
 
- Public Member Functions inherited from pw::async::Dispatcher
virtual void Post (Task &task)
 
virtual void PostAfter (Task &task, chrono::SystemClock::duration delay)
 
virtual void PostAt (Task &task, chrono::SystemClock::time_point time)=0
 
virtual bool Cancel (Task &task)=0
 
virtual SystemClock::time_point now ()=0
 Returns the current time.
 

Protected Member Functions

virtual void ExecuteTask (backend::NativeTask &task, Status status)
 

Additional Inherited Members

- Static Public Member Functions inherited from pw::chrono::VirtualClock< SystemClock >
static VirtualClock< SystemClock > & RealClock ()
 Returns a reference to the real system clock to aid instantiation.
 

Detailed Description

BasicDispatcher is a generic implementation of Dispatcher.

Member Function Documentation

◆ Cancel()

bool pw::async::BasicDispatcher::Cancel ( Task task)
overridevirtual

Prevent a Posted task from starting.

Returns: true: the task was successfully canceled and will not be run by the dispatcher until Posted again. false: the task could not be cancelled because it either was not posted, already ran, or is currently running on the Dispatcher thread.

Implements pw::async::Dispatcher.

◆ ExecuteTask()

virtual void pw::async::BasicDispatcher::ExecuteTask ( backend::NativeTask &  task,
Status  status 
)
protectedvirtual

Execute the given task and provide the status to it.

Note: Once ExecuteTask has finished executing, the task object might have been freed already (e.g. HeapDispatcher).

◆ now()

chrono::SystemClock::time_point pw::async::BasicDispatcher::now ( )
inlineoverridevirtual

Returns the current time.

Implements pw::chrono::VirtualClock< SystemClock >.

◆ PostAt()

void pw::async::BasicDispatcher::PostAt ( Task task,
chrono::SystemClock::time_point  time 
)
overridevirtual

Post caller owned |task| to be run at |time|.

If |task| was already posted to run before |time|, |task| must be run at the earlier time, and |task| may also be run at the later time.

Implements pw::async::Dispatcher.

◆ RequestStop()

void pw::async::BasicDispatcher::RequestStop ( )

Stop processing tasks. If the dispatcher is serving a task loop, break out of the loop, dequeue all waiting tasks, and call their TaskFunctions with a PW_STATUS_CANCELLED status. If no task loop is being served, execute the dequeueing procedure the next time the Dispatcher is run.

◆ Run()

void pw::async::BasicDispatcher::Run ( )
override

Run the dispatcher until RequestStop() is called. Overrides ThreadCore::Run() so that BasicDispatcher is compatible with pw::Thread.

◆ RunFor()

void pw::async::BasicDispatcher::RunFor ( chrono::SystemClock::duration  duration)

Run the dispatcher until duration has elapsed, executing all tasks that come due in that period.

◆ RunUntil()

void pw::async::BasicDispatcher::RunUntil ( chrono::SystemClock::time_point  end_time)

Run the dispatcher until Now() has reached end_time, executing all tasks that come due before then.


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