add_full
Description:
Sets a function to be called at regular intervals, with the given priority.
The function is called repeatedly until it returns [const@GLib.SOURCE_REMOVE], at which point the timeout is automatically destroyed and the
function will not be called again. The notify function is called when the timeout is destroyed. 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).
See [main loop memory management](main-loop.html#memory-management-of-sources) for details on how to handle the return value and memory
management of data.
This internally creates a main loop source using [func@GLib.timeout_source_new] and attaches it to the global [struct@GLib.MainContext] using [ method@GLib.Source.attach], so the callback will be invoked in whichever thread is running that main context. You can do these steps manually if you need greater control or to use a custom main context.
The interval given is in terms of monotonic time, not wall clock time. See [func@GLib.get_monotonic_time].
Parameters:
| priority |
the priority of the timeout source; typically this will be in the range between [const@GLib.PRIORITY_DEFAULT] and [ const@GLib.PRIORITY_HIGH] |
| interval |
the time between calls to the function, in milliseconds |
| function |
function to call |
| data |
data to pass to |
| notify |
function to call when the timeout is removed |
Returns:
|
the ID (greater than 0) of the event source |