on_time(), cancel_time()

#include <oop.h>
#include <sys/time.h>

/* Zero time, for scheduling an event immediately. */
static const struct timeval OOP_TIME_NOW = { 0, 0 };

/* Callback function prototype. */
typedef void *oop_call_time(oop_source *source,struct timeval tv,void *user);

/* Register and unregister time-triggered event sinks. */
void (*on_time)(oop_source *source,struct timeval tv,oop_call_time *call,void *user);
void (*cancel_time)(oop_source *source,struct timeval tv,oop_call_time *call,void *user);

Arguments.

oop_source *source
The event source to register or unregister the event sink with. This must be the same event source you got the function pointer from: "src->on_time(src,...);".

struct timeval tv
The time to wait for. OOP_TIME_NOW (or any time in the past) will cause immediate scheduling.

oop_call_time *call
The callback function (event sink) to add (or remove).

void *user
User data passed through to the callback function.

Description.

Note that these are not global functions, but function pointers supplied by the event source (in the oop_source structure) or by the user.
on_time
After this function is called, when the event loop is running and the time tv is reached (or immediately upon entry to the event loop, if the specified time occurs in the past), the event source will call the function call, passing it a pointer to the event source, the scheduled time, and the same opaque user pointer passed to on_time. This callback will only be called once. Many callbacks may be registered for the same time.

cancel_time
Deactivate an event sink callback registered using on_time (above). If the passed tv, call and user match a previously registered callback, it will be removed; if they match more than one, one of them will be removed; otherwise, no action is taken.

oop_call_time
Called when the event is triggered. Performs a user_specific action. Should return OOP_CONTINUE if the event loop should continue operating; any other value (including OOP_HALT) will cause termination of the event loop.

liboop reference