Open JanDavi opened 8 months ago
void Timer::resetArriveTime() { RWMutex::ReadLock lock(m_event_mutex); std::multimap<int64_t, TimerEvent::ptr> tmp = m_pending_events; lock.unlock(); if (tmp.size() == 0) { DebugLog << "no timerevent pending, size = 0"; return; } auto it = tmp.rbegin(); int64_t interval = (*it).first - getNowMs(); if (interval < 0) { DebugLog << "all timer events has already expire"; return; } timespec ts; memset(&ts, 0, sizeof(ts)); ts.tv_sec = interval / 1000; ts.tv_nsec = (interval % 1000) * 1000000; itimerspec new_value; memset(&new_value, 0, sizeof(new_value)); new_value.it_value = ts; int rt = timerfd_settime(m_fd, 0, &new_value, nullptr); if (rt != 0) { ErrorLog << "tiemr_settime error, interval=" << interval; } else { DebugLog << "reset timer succ, next occur time=" << (*it).first; } }
您好,已收到您的来信,谢谢!