Package: glib

Function g-timeout-add

Lambda List

g-timeout-add (interval func &key priority)

Arguments

interval -- an integer with the time between calls to func, in milliseconds
func -- a g-source-func callback function to call
priority -- an integer with the priority of the timeout source, typically this will be in the range between the +g-priority-default+ and +g-priority-high+ values

Return Value

The unsigned integer ID greater than 0 of the event source.

Details

Sets a function to be called at regular intervals, with priority. The default value is +g-priority-default+. The function is called repeatedly until it returns false, at which point the timeout is automatically destroyed and the function will not be called again. The first call to the function will be at the end of the first interval.

Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval. It does not try to 'catch up' time lost in delays.

If you want to have a timer in the "seconds" range and do not care about the exact time of the first call of the timer, use the g-timeout-add-seconds function. This function allows for more optimizations and more efficient system power usage.

This internally creates a main loop source using the g-timeout-source-new function and attaches it to the main loop context using the g-source-attach function. You can do these steps manually if you need greater control.
 

See also

*2021-12-10