GM provides the following simple alarm API. The alarm API allow the GM client to schedule a callback function to be called after a delay, specified in microseconds. An unbounded number of alarms may be set, although alarm overhead increases linearly in the number of set alarms, and the client must provide storage for each set alarm.
gm_alarm_tstructure for use with
gm_set_alarm(). This function should be called after the structure is allocated but before a pointer to it is passed to
callback(context)to be called after usec microseconds (or later), or reschedule the alarm if it has already been scheduled and has not yet triggered. callback must be non-
NULL. context is treated as an opaque pointer by GM, and may be used to pass a pointer to the client-supplied callback function.
GM clients will also be able to take advantage of the fact that an
application is guaranteed to receive a single
each call to a client-supplied callback, with the corresponding callback
occurring during the call to
gm_unknown() that processes that
alarm. This means that a case statement like the following in the
client's event loops can be used to significantly reduce the overhead of
polling for any effect of a client supplied alarm callback:
case GM_ALARM_EVENT: gm_unknown (event); /* poll for effect of alarm callbacks only here */ break;
Go to the first, previous, next, last section, table of contents.