Esempio n. 1
0
void
Alarm::tick()
{
  Alarm* alarm;
  s_ticks += 1;
  while ((alarm = (Alarm*) s_queue.get_succ()) != (Alarm*) &s_queue) {
    int32_t diff = alarm->m_when - s_ticks;
    if (diff > 0) break;
    alarm->detach();
    alarm->run();
    if (alarm->m_period != 0) {
      alarm->m_when += alarm->m_period;
      alarm->enable();
    }
  }
}
Esempio n. 2
0
void
Alarm::tick()
{
  Alarm* alarm;
  s_ticks += 1;

  // Check for alarms that should be run
  while ((alarm = (Alarm*) s_queue.get_succ()) != (Alarm*) &s_queue) {
    int32_t diff = alarm->m_when - s_ticks;
    if (UNLIKELY(diff > 0)) break;
    alarm->detach();
    alarm->run();
    // Check if the alarm should be rescheduled (periodic)
    if (alarm->m_period != 0) {
      alarm->m_when += alarm->m_period;
      alarm->enable();
    }
  }
}