BasicDispatcher is a generic implementation of Dispatcher. More...
#include <dispatcher.h>
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. | |
![]() | |
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 VirtualClock< SystemClock > & | RealClock () |
Returns a reference to the real system clock to aid instantiation. | |
BasicDispatcher is a generic implementation of Dispatcher.
|
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.