X11 Work Bench Toolkit  1.0
Timer Functions


WB_UINT64 WBGetTimeIndex (void)
 Returns the current 'time index' (in microseconds) More...
int CreateTimer (Display *pDisplay, Window wID, unsigned long lInterval, long lID, int iPeriodic)
 Creates a one-shot or periodic timer. More...
void DeleteTimer (Display *pDisplay, Window wID, long lID)
 Deletes an existing timer's resources. More...

Detailed Description

The X11workbench Toolkit API has support for one-shot and periodic timer events that are generated via XClientEvent using aWM_TIMER.
These timer events are NOT hyper-accurate, although the timer event time is expressed in microseconds (for math efficiency and convenience). The message loop will check for 'crossing an event time' and generate events whenever a limit has been crossed. This means that event processing time can easily affect timer accuracy. Additionally, if a timer's period is less than the processing time of an event, a timer may be 'missed' as a a result. For this reason you should use a worker thread for timing that requires precise accuracy.

Function Documentation

int CreateTimer ( Display *  pDisplay,
Window  wID,
unsigned long  lInterval,
long  lID,
int  iPeriodic 

Creates a one-shot or periodic timer.

pDisplayThe display associated with the specified window
wIDThe window that receives the aWM_TIMER XClientEvent (None == application)
lIntervalThe timer interval in microseconds
lIDThe unique timer identifier
iPeriodicNon-zero for a recurring timer, zero for a 'one-shot' timer.
Non-zero on error, zero on success.

Timers can either be periodic (recurring), or one-shot. Use this function to create them. A timer created by this function must be subsequently deleted via DeleteTimer()

Header File: window_helper.h

Definition at line 3384 of file window_helper.c.

void DeleteTimer ( Display *  pDisplay,
Window  wID,
long  lID 

Deletes an existing timer's resources.

pDisplayThe display associated with the specified window
wIDThe window associated with the timer
lIDThe unique ID associated with the timer

Timers created via CreateTimer() must be subsequently deleted using this function by passing the same Display, Window, and Timer 'unique' ID that were used to create it.

Header File: window_helper.h

Definition at line 3481 of file window_helper.c.

WB_UINT64 WBGetTimeIndex ( void  )

Returns the current 'time index' (in microseconds)

An unsigned 64-bit time index value, in microseconds

The 'time index' is the master timer that determines when a timer event will be generated. By design it uses a 64-bit integer that never 'wraps around' to zero. It is generally derived from the 'gettimeofday' API call for operating systems such as BSD and Linux that support the POSIX standard.

Header File: window_helper.h

Definition at line 3365 of file window_helper.c.