Agar


Note: The Agar manual pages follow certain conventions, notably concerning function return values. Please read AG_Intro(3) first.


SYNOPSIS

#include <agar/core.h>

DESCRIPTION

The AG_Time interface implements useful timing-related routines.

INTERFACE


Uint32 AG_GetTicks (void)

void AG_Delay (Uint32 ms)


The AG_GetTicks() function returns the number of milliseconds elapsed since the Agar library initialization. The value wraps if the program runs for more than approximately 49 days.

AG_Delay() waits at least ms milliseconds (possibly longer depending on OS scheduling), before returning. using the name of the object class as a signature.

INTERNAL INTERFACE

Internally, AG_GetTicks() and AG_Delay() rely on a set of OS-dependent drivers. It is possible to implement new drivers using the following interface:


void AG_SetTimeOps (const AG_TimeOps *ops)


The AG_SetTimeOps() function accepts a pointer to the structure:
typedef struct ag_time_ops {
	const char *name;
	void   (*Init)(void);
	void   (*Destroy)(void);
	Uint32 (*GetTicks)(void);
	void   (*Delay)(Uint32);
} AG_TimeOps;

Init() performs any necessary initialization. Destroy() cleans up any allocated resources.

The GetTicks() operation is the backend to AG_GetTicks() and Delay() is the backend to AG_Delay().

AG_SetTimeOps() can be safely invoked multiple times to change the effective AG_TimeOps.

SEE ALSO

AG_Intro(3), AG_Timeout(3)

HISTORY

The AG_Time interface first appeared in Agar 1.3.4