GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
AG_TIME(3) FreeBSD Library Functions Manual AG_TIME(3)

AG_Timeagar time interface

#include <agar/core.h>

These functions provide a low-level interface to monotonically increasing time sources. Different time backends may be implemented (see INTERNAL API below). Agar provides the following backends:

agTimeOps_dummy
No-op (timers will be unavailable).
agTimeOps_gettimeofday
BSD-style () interface.
agTimeOps_posix
The POSIX () interface.
agTimeOps_renderer
Monotonic clock which stops while graphical rendering is performed. This is useful for applications performing offline rendering, where the render may be influenced by different threads relying on Agar timers or AG_Delay() calls. It requires the POSIX clock_gettime() interface.
agTimeOps_win32
The MS Windows winmm API.

Uint32
AG_GetTicks(void);


void
(Uint32 t);


void
(const AG_TimeOps *ops);

The () function returns the current time in ticks. One tick usually corresponds to one millisecond.

The () function blocks the current thread, waiting at least t ticks before returning. The exact amount of time which AG_Delay() waits is platform and backend dependent.

The () function selects a time backend (see below).

The argument to AG_SetTimeOps() should point to the following structure:

typedef struct ag_time_ops {
	const char *name;
	void   (*Init)(void);
	void   (*Destroy)(void);
	Uint32 (*GetTicks)(void);
	void   (*Delay)(Uint32);
} AG_TimeOps;

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

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

The following code uses AG_GetTicks() to estimate the running time of a routine:

Uint32 t1, t2;

t1 = AG_GetTicks();
MyFunc();
t2 = AG_GetTicks();

AG_Verbose("MyFunc() ran for %u ticks\n",
    t2 - t1);

The following code selects the rendering-aware time backend agTimeOps_renderer if it's available:

#include <agar/config/have_clock_gettime.h>
#include <agar/config/have_pthreads.h>

#if defined(HAVE_CLOCK_GETTIME) && \
    defined(HAVE_PTHREADS)
AG_SetTimeOps(&agTimeOps_renderer);
#endif

AG_Intro(3), AG_Timer(3)

The AG_Time interface first appeared in Agar 1.3.4.

December 21, 2022 Agar 1.7

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.