Pigweed
 
Loading...
Searching...
No Matches
pw::async::HeapDispatcher Class Referencefinal

#include <heap_dispatcher.h>

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

Public Member Functions

 HeapDispatcher (Dispatcher &dispatcher)
 
Status PostAt (TaskFunction &&task_func, chrono::SystemClock::time_point time) override
 Post dispatcher owned |task_func| function to be run at |time|.
 
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::FunctionDispatcher
virtual Status Post (TaskFunction &&task_func)
 Post dispatcher owned |task_func| function.
 
virtual Status PostAfter (TaskFunction &&task_func, chrono::SystemClock::duration delay)
 Post dispatcher owned |task_func| function to be run after |delay|.
 
virtual Status PostAt (TaskFunction &&task_func, chrono::SystemClock::time_point time)=0
 Post dispatcher owned |task_func| function to be run at |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 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.
 

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

HeapDispatcher wraps an existing Dispatcher and allocates Task objects on the heap before posting them to the existing Dispatcher. After Tasks run, they are automatically freed.

Member Function Documentation

◆ Cancel()

bool pw::async::HeapDispatcher::Cancel ( Task task)
inlineoverridevirtual

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.

◆ now()

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

Returns the current time.

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

◆ PostAt() [1/2]

void pw::async::HeapDispatcher::PostAt ( Task task,
chrono::SystemClock::time_point  time 
)
inlineoverridevirtual

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.

◆ PostAt() [2/2]

Status pw::async::HeapDispatcher::PostAt ( TaskFunction &&  task_func,
chrono::SystemClock::time_point  time 
)
overridevirtual

Post dispatcher owned |task_func| function to be run at |time|.

Implements pw::async::FunctionDispatcher.


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