|
FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Schedule jobs at predefined periods of time. More...
#include <fastarduino/scheduler.h>


Public Types | |
| using | CLOCK = CLOCK_ |
The type of clock source used by this Scheduler. More... | |
| using | EVENT = EVENT_ |
The events::Event<T> dispatched by the system and expected by this Scheduler. More... | |
Public Types inherited from containers::Link< T_ > | |
| using | T = T_ |
| The type of item wrapped by this class. More... | |
Public Types inherited from containers::LinkedList< Job > | |
| using | T = Job |
| The type of items in this list. More... | |
Public Member Functions | |
| Scheduler (const Scheduler &)=delete | |
| Scheduler & | operator= (const Scheduler &)=delete |
| Scheduler (const CLOCK &clock, uint8_t type) INLINE | |
Create a new Scheduler based on the given clock. More... | |
| void | schedule (Job &job) INLINE |
Add job to this scheduler. More... | |
| void | unschedule (Job &job) INLINE |
Remove job from this scheduler. More... | |
Public Member Functions inherited from events::EventHandler< EVENT_ > | |
| uint8_t | type () const INLINE |
| The type of event that this handler accepts and can act upon. More... | |
Public Member Functions inherited from containers::LinkedList< Job > | |
| void | insert (T &item) INLINE |
Insert item at the beginning of this list. More... | |
| bool | remove (T &item) INLINE |
Remove item from this list. More... | |
| void | traverse (F func) |
Traverse all items of this list and execute f functor. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from events::EventHandler< EVENT_ > | |
| virtual void | on_event (const EVENT_ &event)=0 |
This pure virtual method is called by Dispatcher::dispatch() when event.type() matches the type supported by this EventHandler. More... | |
| EventHandler (uint8_t type=Type::NO_EVENT) INLINE | |
Create an Event Handler for given type of event. More... | |
Schedule jobs at predefined periods of time.
The timebase is provided by CLOCK clock instance. A scheduler is an EventHandler that must thus be attached to a Dispatcher as in this snippet:
In that snippet, we use Watchdog as the clock source, but other sources are available.
| CLOCK_ | the type of clock that will be used as time base |
| EVENT_ | the events::Event<T> dispatched by the system |
Definition at line 88 of file scheduler.h.
| using events::Scheduler< CLOCK_, EVENT_ >::CLOCK = CLOCK_ |
The type of clock source used by this Scheduler.
Definition at line 95 of file scheduler.h.
| using events::Scheduler< CLOCK_, EVENT_ >::EVENT = EVENT_ |
The events::Event<T> dispatched by the system and expected by this Scheduler.
Definition at line 97 of file scheduler.h.
|
inline |
Create a new Scheduler based on the given clock.
| clock | the clock providing the timebase for this scheduler |
| type | the type of event generated by clock |
Definition at line 104 of file scheduler.h.
|
inline |
Add job to this scheduler.
| job | the job to be added to this scheduler |
Definition at line 118 of file scheduler.h.
|
inline |
Remove job from this scheduler.
Note that when a job is not periodic (i.e. it is a one-shot job) then it is automatically unscheduled after first execution.
| job | the job to be removed from this scheduler; does nothing if job was not previously added to this scheduler. |
Definition at line 131 of file scheduler.h.