31 using Duration = QAbstractEventDispatcher::Duration;
32 using TimePoint = std::chrono::time_point<std::chrono::steady_clock, Duration>;
33 QTimerInfo(Qt::TimerId timerId, Duration interval, Qt::TimerType type, QObject *obj)
34 : interval(interval), id(timerId), timerType(type), obj(obj)
38 TimePoint timeout = {};
39 Duration interval = Duration{-1};
40 Qt::TimerId id = Qt::TimerId::Invalid;
41 Qt::TimerType timerType;
42 QObject *obj =
nullptr;
43 QTimerInfo **activateRef =
nullptr;
49 using Duration = QAbstractEventDispatcher::Duration;
50 using TimerInfo = QAbstractEventDispatcher::TimerInfoV2;
53 mutable std::chrono::steady_clock::time_point currentTime;
55 std::optional<Duration> timerWait();
56 void timerInsert(QTimerInfo *);
58 Duration remainingDuration(Qt::TimerId timerId)
const;
60 void registerTimer(Qt::TimerId timerId, Duration interval,
61 Qt::TimerType timerType, QObject *object);
62 bool unregisterTimer(Qt::TimerId timerId);
63 bool unregisterTimers(QObject *object);
64 QList<TimerInfo> registeredTimers(QObject *object)
const;
67 bool hasPendingTimers();
75 bool isEmpty()
const {
return timers.empty(); }
77 qsizetype size()
const {
return timers.size(); }
79 auto findTimerById(Qt::TimerId timerId)
const
81 auto matchesId = [timerId](
const auto &t) {
return t->id == timerId; };
82 return std::find_if(timers.cbegin(), timers.cend(), matchesId);
86 std::chrono::steady_clock::time_point updateCurrentTime()
const;
89 QTimerInfo *firstTimerInfo =
nullptr;
90 QList<QTimerInfo *> timers;