NAME

cxTimerAdd - register an interval timer
#include <cx/Timer.h>

void *cxTimerAdd(int ms, int retrip, void (*callback)(void *), void *client)
integer function cxTimerAdd(ms, retrip, callback, client)
integer ms, retrip
integer client
integer callback
ms
The number of milliseconds of delay wanted.
retrip
Non-zero value means that this timer should reset itself and start timing down once it has tripped and called the user callback routine.
callback
The user callback routine. This subroutine is called by the control wrapper when the timer has expired.
client
Arbitrary client data. This value is passed to the user callback routine when the time expires.
cxTimerAdd implements a timing facility for IRIS Explorer modules. A module may request that one of its callback routines be called after a delay, or be called periodically. cxTimerAdd returns an opaque pointer which can subsequently be used to remove the timer by using cxTimerRemove.

The first parameter, ms, says how many milliseconds to delay. Once that period has elapsed, the routine callback will be called from the control wrapper; it will be given the value of clientdata as its sole parameter. Once the user callback has returned, if retrip is non-zero, the timer will be set back to the value ms and timing will continue.

Because timing is performed as a part of the event processing loop within the control wrapper, if the timer expires while the user function is executing, and the user function retains control for a long period of time, the callback will not be called on schedule.

The following is an example of how to use this routine:

/*
** This is the user-defined timer callback routine
*/

void myCallback(void *data) { /* Do whatever needs to be done */ }
/* ** This is a code segment from the user function ** or the initialization hook function. */
void *timerHandle;
timerHandle = cxTimerAdd(250, 1, myCallback, myClientData);

In this example, the function myCallback will be called from the control wrapper every 250 milliseconds.

Note:
This timing facility is not available to modules that link with the X Window System. Timing in those modules must be managed by XtAddTimeOut.
cxTimerRemove(3E), XtAddTimeOut(3X)
Last modified: Mon Nov 6 16:33:50 GMT 2000
[ Documentation Home ]
© The Numerical Algorithms Group Ltd, Oxford UK. 1996