A timer is a Gamma expression that is submitted for
evaluation at specified time in the future. Timer related events are set up
through the every and
after functions
which provide a relative time delay, and the at function which accepts an absolute time. These
functions accept timing parameters and a block of code that will be
evaluated when the timer expires. The code can be simply a function name, or
can be an entire expression to be evaluated.
A timer will only be handled during a call to
next_event, next_event_nb or
flush_events. If a timer expires while another operation
is being performed, the engine will evaluate the timer code at the next
event handling instruction.
In the Gamma language, by default, timers are internally handled by using proxies. A proxy is non-blocking system message that does not require a reply. The Gamma engine can act on a proxy immediately, or delay a little while in order to finish what it is currently doing. It is this 'little while' that becomes the limit of the accuracy of the timers in a Gamma program when they are driven from proxies. You see, most Gamma programs are run through an event loop. The maximum time a proxy-based timer can be delayed is the execution time of the longest path of code attached to an event. Since this quantity is totally dependent on how your code is written and the speed of your CPU, it is difficult to put an exact number on the practical accuracy of Gamma proxy-based timers. The maximum resolution of the timers is equal to the OS tick size setting.
A timer is created when any of the following functions are called:
The after timer
is used to evaluate a piece of code after a given amount of time. It is
a one-shot timer that "goes away" after being fired.
The every timer
is used to evaluate a piece of code at a specified interval.
The at
timer evaluates the associated code when the current time matches
the profile created by six arguments to the function.
For syntax and examples see the Reference Manual.