Beispiel #1
0
void sampgdk_timer_process_timers(void *plugin) {
  long now;
  long elapsed;
  int i;
  struct sampgdk_timer *timer;

  assert(plugin != NULL);

  now = sampgdk_timer_clock();

  for (i = 0; i < timers.count; i++) {
    timer = sampgdk_array_get(&timers, i);

    if (!timer->is_set) {
      continue;
    }

    if (plugin != NULL && timer->plugin != plugin) {
      continue;
    }

    elapsed = now - timer->started;

    if (elapsed >= timer->interval) {
      fire_timer(i + 1, elapsed);
    }
  }
}
Beispiel #2
0
/**
 * the function to be called with each tick
 */
void
timer_tick_processor(void)
{
  uint32_t timer_idx;

  while((timer_idx = (uint32_t) ((long int)lpop(&timerwheel[timerwheel_idx]))) != 0) {
    fire_timer(timer_idx);
  }
  if(++timerwheel_idx >= TIMER_WHEEL_SIZE) {
    timerwheel_idx = 0;
  }
}