# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
> I'm using a standard timer with which resets itself at the end of its
> own call-back, therefore re-triggering itself (a 'heartbeat').
By timer, I assume you mean the Timer object.
> This works beautifully, except when there is a lot of other stuff
> happening grabbing CPU time, then the timer starts piling up
> call-backs, which all get serviced in a rush when there is a gap in
> the processing time.
>
> I can't seem to lengthen the timer easily when I know this will
> happen, and I'm not certain how best to use the X-event queue
> manipulation stuff.
You probably don't want to muck with the X Event queue.
You might check to see if the timeout (fl_add_timeout()) does a better
job.
A possible alternative is to use the gettimeofday() to check whether
the callback really needs to do anything:
void your_callback( FL_OBJECT *obj, long data )
{
static double last_tick = 0;
struct timeval tv;
double this_tick;
gettimeofday( &tv, NULL );
this_tick = tv.tv_sec + ( tv.tv_usec * 1.0e-6 );
if ( this_tick - last_tick > MINIMUM_INTERVAL ) {
do_the_real_callback_action( obj, data );
last_tick = this_tick;
}
}
It's a hack.
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Tue Apr 11 2000 - 21:24:29 EDT