ext/iodine/fio.c
/** Returns the number of miliseconds until the next event, up to FIO_POLL_TICK
 */
Returns the number of miliseconds until the next event, up to FIO_POLL_TICK
Returns the number of miliseconds until the next event up to FIO_POLL_TICK
static size_t fio_timer_calc_first_interval(void) {
  if (fio_defer_has_queue())
    return 0;
  if (fio_ls_embd_is_empty(&fio_timers)) {
    return FIO_POLL_TICK;
  }
  struct timespec now = fio_last_tick();
  struct timespec due =
      FIO_LS_EMBD_OBJ(fio_timer_s, node, fio_timers.next)->due;
  if (due.tv_sec < now.tv_sec ||
      (due.tv_sec == now.tv_sec && due.tv_nsec <= now.tv_nsec))
    return 0;
  size_t interval = 1000L * (due.tv_sec - now.tv_sec);
  if (due.tv_nsec >= now.tv_nsec) {
    interval += (due.tv_nsec - now.tv_nsec) / 1000000L;
  } else {
    interval -= (now.tv_nsec - due.tv_nsec) / 1000000L;
  }
  if (interval > FIO_POLL_TICK)
    interval = FIO_POLL_TICK;
  return interval;
}
static size_t fio_timer_calc_first_interval ( void ) { if ( fio_defer_has_queue ( ) ) return 0 ; if ( fio_ls_embd_is_empty ( & fio_timers ) ) { return FIO_POLL_TICK ; } struct timespec now = fio_last_tick ( ) ; struct timespec due = FIO_LS_EMBD_OBJ ( fio_timer_s , node , fio_timers . next ) -> due ; if ( due . tv_sec < now . tv_sec || ( due . tv_sec == now . tv_sec && due . tv_nsec <= now . tv_nsec ) ) return 0 ; size_t interval = 1000L * ( due . tv_sec - now . tv_sec ) ; if ( due . tv_nsec >= now . tv_nsec ) { interval += ( due . tv_nsec - now . tv_nsec ) / 1000000L ; } else { interval -= ( now . tv_nsec - due . tv_nsec ) / 1000000L ; } if ( interval > FIO_POLL_TICK ) interval = FIO_POLL_TICK ; return interval ; }
Returns the number of miliseconds until the next event, up to FIO_POLL_TICK
Returns the number of miliseconds until the next event up to FIO_POLL_TICK