void TimerQueue::handleRead() { loop_->assertInLoopThread(); Timestamp now(Timestamp::now()); readTimerfd(timerfd_, now); std::vector<Entry> expired = getExpired(now); callingExpiredTimers_ = true; cancelingTimers_.clear(); // safe to callback outside critical section for (std::vector<Entry>::iterator it = expired.begin(); it != expired.end(); ++it) { it->second->run(); } callingExpiredTimers_ = false; reset(expired, now); }
void Timer::handleRead() { _loop->assertInLoopThread(); Time now(Time::now()); util::readTimerfd(_timerfd, now); std::vector<Entry> expired = getExpired(now); _callingExpiredTasks = true; _cancelingTasks.clear(); // safe to callback outside critical section for (std::vector<Entry>::iterator it = expired.begin(); it != expired.end(); ++it) { it->second->run(); } _callingExpiredTasks = false; reset(expired, now); }