MCPcopy Create free account
hub / github.com/deskflow/deskflow / hasTimerExpired

Method hasTimerExpired

src/lib/base/EventQueue.cpp:341–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341bool EventQueue::hasTimerExpired(Event &event)
342{
343 // return true if there's a timer in the timer priority queue that
344 // has expired. if returning true then fill in event appropriately
345 // and reset and reinsert the timer.
346 if (m_timerQueue.empty()) {
347 return false;
348 }
349
350 // get time elapsed since last check
351 const double time = m_time.getTime();
352 m_time.reset();
353
354 // countdown elapsed time
355 for (auto index = m_timerQueue.begin(); index != m_timerQueue.end(); ++index) {
356 (*index) -= time;
357 }
358
359 // done if no timers are expired
360 if (m_timerQueue.top() > 0.0) {
361 return false;
362 }
363
364 // remove timer from queue
365 Timer timer = m_timerQueue.top();
366 m_timerQueue.pop();
367
368 // prepare event and reset the timer's clock
369 timer.fillEvent(m_timerEvent);
370 event = Event(EventTypes::Timer, timer.getTarget(), &m_timerEvent);
371 timer.reset();
372
373 // reinsert timer into queue if it's not a one-shot
374 if (!timer.isOneShot()) {
375 m_timerQueue.push(timer);
376 }
377
378 return true;
379}
380
381double EventQueue::getNextTimerTimeout() const
382{

Callers

nothing calls this directly

Calls 11

fillEventMethod · 0.80
isOneShotMethod · 0.80
pushMethod · 0.80
EventClass · 0.70
emptyMethod · 0.45
getTimeMethod · 0.45
resetMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
popMethod · 0.45
getTargetMethod · 0.45

Tested by

no test coverage detected