|
NAMEAG_Timer —
agar timer facility
SYNOPSIS#include <agar/core.h> DESCRIPTIONTheAG_Timer structure describes a unique timer, which
may or may not be associated with some parent
AG_Object(3).
If a timer has a parent object, Agar will guarantee cancellation of any
callbacks if the parent object is destroyed or detached. When a timer expires,
its callback routine is executed. Timer callback routines should be defined
as:
The timer argument, and the list of
arguments under event are those previously specified
in The timer's parent object is guaranteed to remain locked during
the execution of the callback. The context of execution of the callback is
platform-dependent. On platforms where
kqueue(2)
is available, the routine is executed in the event loop. On platforms where
only POSIX timers are available, the routine is executed in a separate
thread. On platforms which don't provide any timer interface at all, the
event loop repeatedly calls INTERFACEvoidAG_InitTimer (AG_Timer
*timer, const char
*name, Uint flags);
The
The Timers created with The The The In the timer callback routine, it is safe to make
The AG_LockTimers(obj); if (AG_TimerIsRunning(obj, &timer)) { ... } AG_UnlockTimers(obj); The SPECIALIZED TIMERSTheAG_Timer interface is not tied to any specific time
source. A timer's parent object may influence the way timers are processed.
By default, the execution of timers is based on the progress of a monotonic system clock and one "tick" is roughly equivalent to one millisecond. However, it is possible for different parent objects to process time differently. For example, an object in a simulation application might manage its timers using use some software-defined time, or an offline renderer might require that logic time be stopped during rendering (see AG_Time(3)). SEE ALSOAG_Event(3), AG_GetTicks(3), AG_Intro(3), AG_Object(3), AG_SchedEvent(3), AG_Time(3)George Varghese and Tony Lauck, Hashed and Hierarchical Timing Wheels: Efficient Data Structures for Implementing a Timer Facility, February 14, 1996. HISTORYTheAG_Timer facility first appeared in Agar 1.0 as
AG_Timeout, and was modeled after the OpenBSD
timeout(9)
API by Artur Grabowski and Thomas Nordin. In Agar 1.5.0, callback routines
were allowed to accept multiple arguments, and support for
kqueue(2)
was added.
Visit the GSP FreeBSD Man Page Interface. |