void Timer::pollTimers() { assert_ui_thread(); // Generate messages for timers if (running_timers != 0) { ASSERT(!timers.empty()); base::tick_t t = base::current_tick(); for (auto timer : timers) { if (timer && timer->isRunning()) { int64_t count = ((t - timer->m_lastTick) / timer->m_interval); if (count > 0) { timer->m_lastTick += count * timer->m_interval; ASSERT(timer->m_owner != nullptr); Message* msg = new TimerMessage(count, timer); msg->setRecipient(timer->m_owner); Manager::getDefault()->enqueueMessage(msg); } } } } }
void Timer::pollTimers() { // Generate messages for timers if (!timers.empty()) { int t = ji_clock; int count; for (Timers::iterator it=timers.begin(), end=timers.end(); it != end; ++it) { Timer* timer = *it; if (timer && timer->m_lastTime >= 0) { count = 0; while (t - timer->m_lastTime > timer->m_interval) { timer->m_lastTime += timer->m_interval; ++count; /* we spend too much time here */ if (ji_clock - t > timer->m_interval) { timer->m_lastTime = ji_clock; break; } } if (count > 0) { ASSERT(timer->m_owner != NULL); Message* msg = new TimerMessage(count, timer); msg->addRecipient(timer->m_owner); Manager::getDefault()->enqueueMessage(msg); } } } } }
bool Timer::haveTimers() { return !timers.empty(); }
void Timer::checkNoTimers() { ASSERT(timers.empty()); }