FastArduino  v1.7
C++ library to build fast but small Arduino/AVR projects
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.
 
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.
 
void reschedule (uint32_t when) INLINE
 Reschedule this job for a later time (in ms). More...
 

Protected Member Functions

 Job (const Job &)=default
 
Joboperator= (const Job &)=default
 
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 222 of file scheduler.h.

Member Function Documentation

◆ 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.

◆ 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

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