Class of objects that triggers a function continuously in a regular rate. It also avoids accumulation of triggering events if the function execution overlaps the time of the next event. In such case, the overlapped event is canceled. This class is useful to implement monitors that are executed from time to time in a cooperative multi-threaded application.
Each instance is bounded to an instance of
Scheduler which is used to register a thread that executes continuously the triggered function and sleeps until the time for the next execution.
It also measures the time the function execution lasted in order to avoid accumulation of delayed execution.
objectan instance of
Timer. It also creates the thread that continously executes the defined action. If no
objectis provided, a new table is created to represent the new instance.
- Function called at each triggering event.
Boolean value that indicates if the timer is enabled or not.
This field should not be changed by the application.
To do so, use the methods
Time rate, in seconds, that the function
actionshould be executed.
Object that implements the API of
Schedulerand is used to register the thread that executes the timer.
Co-routine that implements the thread that executes the timer.
This thread is registered in the object of field
schedulerwhen the timer is enabled.
- Method that implements the timer behavior. This is the function executed by the timer thread.
- Method that enables the execution of the timer to start triggering the defined action.
- Method that disables the execution of the timer preventing that the action be executed again.
The time precision of the timer depends on the precision provided by object of field
-- example missing