C/C++ API Reference
Loading...
Searching...
No Matches
pw_async_basic

Oveview

Main docs: https://pigweed.dev/pw_async_basic.

Classes

class  pw::async::BasicDispatcher
 BasicDispatcher is a generic implementation of Dispatcher. More...
 

Functions

void pw::async::BasicDispatcher::RunUntilIdle ()
 Execute all runnable tasks and return without waiting.
 
void pw::async::BasicDispatcher::RunUntil (chrono::SystemClock::time_point end_time)
 
void pw::async::BasicDispatcher::RunFor (chrono::SystemClock::duration duration)
 
void pw::async::BasicDispatcher::RequestStop ()
 
void pw::async::BasicDispatcher::Run () override
 
void pw::async::BasicDispatcher::PostAt (Task &task, chrono::SystemClock::time_point time) override
 
bool pw::async::BasicDispatcher::Cancel (Task &task) override
 
chrono::SystemClock::time_point pw::async::BasicDispatcher::now () override
 Returns the current time.
 
virtual void pw::async::BasicDispatcher::ExecuteTask (backend::NativeTask &task, Status status)
 

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.