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.
Classes | |
| class | RunOneTaskResult |
| class | SleepInfo |
Public Member Functions | |
| NativeDispatcherBase (NativeDispatcherBase &)=delete | |
| NativeDispatcherBase (NativeDispatcherBase &&)=delete | |
| NativeDispatcherBase & | operator= (NativeDispatcherBase &)=delete |
| NativeDispatcherBase & | operator= (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) |
| uint32_t | tasks_polled () const |
| uint32_t | tasks_completed () const |
| uint32_t | sleep_count () const |
| uint32_t | wake_count () const |
Private Member Functions | |
| virtual void | DoWake ()=0 |
Friends | |
| class | Dispatcher |
| class | Task |
| class | Waker |
|
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.
| allow_empty | Whether or not to allow sleeping when no tasks are registered. |
|
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.
|
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 impl::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.
|
protected |
Attempts to run a single task, returning whether any tasks were run, and whether task_to_look_for was run.