libkeepalive
Loading...
Searching...
No Matches
keepalive-timeout.h File Reference

Provides suspend aware timers with glib timeout compatible API. More...

#include <glib.h>

Go to the source code of this file.

Functions

guint keepalive_timeout_add_full (gint priority, guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify)
 
guint keepalive_timeout_add (guint interval, GSourceFunc function, gpointer data)
 
guint keepalive_timeout_add_seconds_full (gint priority, guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify)
 
guint keepalive_timeout_add_seconds (guint interval, GSourceFunc function, gpointer data)
 

Detailed Description

Provides suspend aware timers with glib timeout compatible API.

Function Documentation

◆ keepalive_timeout_add_full()

guint keepalive_timeout_add_full ( gint priority,
guint interval,
GSourceFunc function,
gpointer data,
GDestroyNotify notify )

Drop in replacement for g_timeout_add_full()

Unlike normal glib timers, these can wake the device from suspend and keep the device from suspending while the callback function is executed by using IPHB wakeups from DSME and CPU-keepalive from MCE.

Note that the wakeup time is not exact.

The IPHB wakeups use 1 second resolution, so the milliseconds used due to following the glib interface are rounded up to the next full second.

If the device needs to wake up from suspend, that happens via RTC alarm interrupts. In that case clock source differences can cause up to one second jitter in wakeups.

And the triggering is scheduled via ranged IPHB wakeup. By default the range that is used is [interval, interval + heartbeat seconds] - which should guarantee that the device will not wake up solely to serve the timer, but also means the wakeup can occur up to 12 seconds later than requested.

If more exact wakeup is absolutely required, the priority parameter of G_PRIORITY_HIGH can be used and the wakeup is scheduled to occur at range of [interval, interval + 1 second].

Parameters
prioritythe priority of the timeout source. Typically this will be in the range between G_PRIORITY_DEFAULT and G_PRIORITY_HIGH.
intervalthe time between calls to the function, in milliseconds
functionfunction to call
datadata to pass to function
notifyfunction to call when the timeout is removed, or NULL.
Returns
the ID (greater than 0) of the event source

◆ keepalive_timeout_add()

guint keepalive_timeout_add ( guint interval,
GSourceFunc function,
gpointer data )

Drop in replacement for g_timeout_add()

See keepalive_timeout_add_full() for details.

Parameters
intervalthe time between calls to the function, in milliseconds
functionfunction to call
datadata to pass to function
Returns
the ID (greater than 0) of the event source

◆ keepalive_timeout_add_seconds_full()

guint keepalive_timeout_add_seconds_full ( gint priority,
guint interval,
GSourceFunc function,
gpointer data,
GDestroyNotify notify )

Drop in replacement for g_timeout_add_seconds_full()

See keepalive_timeout_add_full() for details.

Parameters
prioritythe priority of the timeout source. Typically this will be in the range between G_PRIORITY_DEFAULT and G_PRIORITY_HIGH.
intervalthe time between calls to the function, in seconds
functionfunction to call
datadata to pass to function
notifyfunction to call when the timeout is removed, or NULL.
Returns
the ID (greater than 0) of the event source

◆ keepalive_timeout_add_seconds()

guint keepalive_timeout_add_seconds ( guint interval,
GSourceFunc function,
gpointer data )

Drop in replacement for g_timeout_add_seconds()

See keepalive_timeout_add_full() for details.

Parameters
intervalthe time between calls to the function, in seconds
functionfunction to call
datadata to pass to function
Returns
the ID (greater than 0) of the event source
Examples
simple-timer-wakeup.c.