FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
events::Job Class Referenceabstract

Abstract class holding some action to be executed at given periods of time. More...

#include <fastarduino/scheduler.h>

Inheritance diagram for events::Job:
Collaboration diagram for events::Job:

Public Member Functions

bool is_periodic () const INLINE
 Tell if this job is periodic or not. More...
 
uint32_t next_time () const INLINE
 Tell next time (in ms) when this job shall be executed. More...
 
uint32_t period () const INLINE
 Return the period of this job, or 0 if this is a one-shot job. More...
 
void reschedule (uint32_t when) INLINE
 Reschedule this job for a later time (in ms). More...
 

Protected Member Functions

virtual void on_schedule (uint32_t millis)=0
 This method is called by Scheduler whenever current clock time is greater or equal to next_time(). More...
 
 Job (uint32_t next=0, uint32_t period=0) INLINE
 Construct a new Job. More...
 

Friends

template<typename CLOCK , typename T >
class Scheduler
 

Additional Inherited Members

Detailed Description

Abstract class holding some action to be executed at given periods of time.

You should subclass Job and implement virtual method on_schedule(). A Job may be "one-shot" (executed exactly once) or "periodic" (executed at regular time intervals). Every job must be added to a Scheduler in order to be executed at specified time.

See also
Scheduler::schedule()

Definition at line 160 of file scheduler.h.

Constructor & Destructor Documentation

◆ Job()

events::Job::Job ( uint32_t  next = 0,
uint32_t  period = 0 
)
inlineprotected

Construct a new Job.

Parameters
nextnext time (in ms) at which this job shall be executed the first time
periodthe period (in ms) at which this job shall be periodically executed, or 0 if this must be a one-shot job.

Definition at line 224 of file scheduler.h.

Member Function Documentation

◆ is_periodic()

bool events::Job::is_periodic ( ) const
inline

Tell if this job is periodic or not.

Definition at line 166 of file scheduler.h.

◆ next_time()

uint32_t events::Job::next_time ( ) const
inline

Tell next time (in ms) when this job shall be executed.

Time reference for this value is provided by the Scheduler clock.

Definition at line 175 of file scheduler.h.

◆ period()

uint32_t events::Job::period ( ) const
inline

Return the period of this job, or 0 if this is a one-shot job.

Definition at line 183 of file scheduler.h.

◆ reschedule()

void events::Job::reschedule ( uint32_t  when)
inline

Reschedule this job for a later time (in ms).

Time reference for when is provided by the Scheduler clock. This gets automatically called by Scheduler after every execution of a periodic job.

Parameters
whennext time (in ms) at which this job shall be executed; note that actual execution time accuracy depends a lot on how busy your main event loop is.

Definition at line 197 of file scheduler.h.

◆ on_schedule()

virtual void events::Job::on_schedule ( uint32_t  millis)
protectedpure virtual

This method is called by Scheduler whenever current clock time is greater or equal to next_time().

You must override this method to make it perform what you need.

Parameters
millisthe current time at which this method is called, as provided by Scheduler clock

Friends And Related Function Documentation

◆ Scheduler

template<typename CLOCK , typename T >
friend class Scheduler
friend

Definition at line 230 of file scheduler.h.


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