Skip to content

DS_CAP_TIMERS

Denis Stepanov edited this page Apr 25, 2021 · 15 revisions

DS_CAP_TIMERS — Timer Support

Description

This capability add support for timers, used to execute certain actions in future. The way to define future event is determined by timer type. Grossly, there are two ways of designating future time: absolute (when system has notion of system time and can be programmed for a future timestamp) and relative (when system does not have notion of time but can be programmed for some time in future using some time counting technique relative to the original time point). The library supports several timer types:

Timer actions are specified using a string called "action". When timer event fires, the library calls a user-defined callback function, which can check the timer "action" property in order to decide which code to execute.

This capability defines an abstract timer interface (ds::Timer class); in order to actually use a timer, user has to select one of the four timer implementations listed above. ds::Timer class has the following fields implemented:

Field Type Description Default Value
id int Timer identifier (optional) -1
type ds::timer_type_t Timer type (none)
action String Timer action "undefined"
armed bool True if timer is armed (will fire); false if ignored with no action true
recurrent bool True if timer should be auto-rearmed after firing; false otherwise true
transient bool True if timer should be disposed of after firing false

Marking timer as transient will render it unusable (destroy) after firing once. This normally only has meaning in the context of collection of timers, in which case the timer will be deleted from collection.

Requires

None.

Cooperates With

None.

Conflicts With

None.

Usage

None. See the corresponding timer implementations.

Mandatory Calls

System::begin() Not required
System::update() Not required

Note that while this capability per se does not these calls, the underlying implementations, like absolute timer, would most likely need them to work correctly. Check their respective pages for details.

Examples

Bugs

None.

See Also