Example #1
0
File: event.c Project: barak/lush
/* timer_abs --
 * Add a timer targeted to the specified handler
 * firing at the specified date.
 */
void *timer_abs(at *handler, double date)
{
   int sec = (int)date;
   int msec = (date - sec) * 1000;
   if (!handler)
      RAISEF("invalid event handler", handler);
   return timer_add_sub(handler, sec, msec, 0);
}
Example #2
0
/* timer_abs --
   Add a timer targeted to the specified handler
   firing at the specified date.
*/
void *
timer_abs(at *handler, real date)
{
  int sec = (int)date;
  int msec = (date - sec) * 1000;
  if (! handler)
    error(NIL,"Illegal null event handler",NIL);
  return timer_add_sub(handler, sec, msec, 0);
}
Example #3
0
File: event.c Project: barak/lush
/* timer_add --
 * Add a timer targeted to the specified handler
 * firing after delay milliseconds and every period
 * milliseconds after that.  Specifying period equal 
 * to zero sets a one shot timer.
 */
void *timer_add(at *handler, int delay, int period)
{
   evtime_t now, add;
   evtime_now(&now);
   if (!handler)
      RAISEF("invalid event handler", handler);
   if (delay < 0)
      RAISEF("invalid timer delay", NEW_NUMBER(delay));
   if (period < 0)
      RAISEF("invalid timer interval", NEW_NUMBER(period));
   if (period > 0 && period < 20)
      period = 20;
   add.sec = delay/1000;
   add.msec = delay%1000;
   evtime_add(&now, &add, &add);
   return timer_add_sub(handler, add.sec, add.msec, period);
}
Example #4
0
/* timer_add --
   Add a timer targeted to the specified handler
   firing after delay milliseconds and every period
   milliseconds after that.  Specifying period equal 
   to zero sets a one shot timer.
*/
void *
timer_add(at *handler, int delay, int period)
{
  evtime_t now, add;
  evtime_now(&now);
  if (! handler)
    error(NIL,"Illegal null event handler",NIL);
  if (delay < 0)
    error(NIL,"Illegal timer delay",NEW_NUMBER(delay));
  if (period < 0)
    error(NIL,"Illegal timer interval",NEW_NUMBER(period));
  if (period > 0 && period < 20)
    period = 20;
  add.sec = delay/1000;
  add.msec = delay%1000;
  evtime_add(&now, &add, &add);
  return timer_add_sub(handler, add.sec, add.msec, period);
}