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) |
|
overridevirtual |
Prevent a Post
ed task from starting.
Returns: true: the task was successfully canceled and will not be run by the dispatcher until Post
ed 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.
|
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).
|
inlineoverridevirtual |
Returns the current time.
Implements pw::chrono::VirtualClock< SystemClock >.
|
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.
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.
|
override |
Run the dispatcher until RequestStop() is called. Overrides ThreadCore::Run() so that BasicDispatcher is compatible with pw::Thread.
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.
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.