libkeepalive
|
Provides wrapper API for libiphb wakeups. More...
#include <stdbool.h>
Go to the source code of this file.
Typedefs | |
typedef struct heartbeat_t | heartbeat_t |
typedef void(* | heartbeat_wakeup_fn) (void *aptr) |
typedef void(* | heartbeat_free_fn) (void *aptr) |
Functions | |
heartbeat_t * | heartbeat_new (void) |
heartbeat_t * | heartbeat_ref (heartbeat_t *self) |
void | heartbeat_unref (heartbeat_t *self) |
void | heartbeat_set_delay (heartbeat_t *self, int delay_lo, int delay_hi) |
void | heartbeat_set_notify (heartbeat_t *self, heartbeat_wakeup_fn notify_cb, void *user_data, heartbeat_free_fn user_free_cb) |
void | heartbeat_start (heartbeat_t *self) |
void | heartbeat_stop (heartbeat_t *self) |
Provides wrapper API for libiphb wakeups.
typedef struct heartbeat_t heartbeat_t |
Opaque heartbeat wakeup object
Allocate via heartbeat_new() and release via heartbeat_unref().
typedef void(* heartbeat_wakeup_fn) (void *aptr) |
Hearbeat wakeup function type
aptr | user_data set via heartbeat_set_notify() |
typedef void(* heartbeat_free_fn) (void *aptr) |
User data free function type
Called when heartbeat object is deleted after the final reference is dropped via heartbeat_unref(), or when heartbeat_set_notify() is called while user_data is already set.
user_data | set via heartbeat_set_notify() |
heartbeat_t * heartbeat_new | ( | void | ) |
Create heartbeat wakeup object
Initially has reference count of 1.
Use heartbeat_ref() to increment reference count and heartbeat_unref() to decrement reference count.
Will be automatically released after reference count drops to zero.
heartbeat_t * heartbeat_ref | ( | heartbeat_t * | self | ) |
Increment reference count of heartbeat wakeup object
Passing NULL object is explicitly allowed and does nothing.
self | heartbeat wakeup object pointer |
void heartbeat_unref | ( | heartbeat_t * | self | ) |
Decrement reference count of heartbeat wakeup object
Passing NULL object is explicitly allowed and does nothing.
The object will be released if reference count reaches zero.
self | heartbeat wakeup object pointer |
void heartbeat_set_delay | ( | heartbeat_t * | self, |
int | delay_lo, | ||
int | delay_hi ) |
Set wakeup delay range
If delay_lo == delay_hi, the value specifies global wakeup slot rather seconds from current time.
If delay_hi < delay_lo, then the upper bound is adjusted so that it is delay_lo + heartbeat interval (=12 seconds, but may vary from one device to another).
self | heartbeat wakeup object pointer |
delay_lo | minimum seconds to wakeup |
delay_hi | maximum seconds to wakeup |
void heartbeat_set_notify | ( | heartbeat_t * | self, |
heartbeat_wakeup_fn | notify_cb, | ||
void * | user_data, | ||
heartbeat_free_fn | user_free_cb ) |
Set notification callback function to use on hearbeat wakeup
If non-null user_free_cb is given, it is assumed that heartbeat wakeup object owns user_data and it will be released when heartbeat object is deleted or when heartbeat_set_notify() is called again.
self | heartbeat wakeup object pointer |
notify_cb | callback function pointer, or NULL |
user_data | data to pass to callback function |
user_free_cb | callback function for releasing user_data |
void heartbeat_start | ( | heartbeat_t * | self | ) |
Start waiting for heartbeat wakeup
self | heartbeat wakeup object pointer |
void heartbeat_stop | ( | heartbeat_t * | self | ) |
Cancel already scheduled heartbeat wakeup
self | heartbeat wakeup object pointer |