Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtimerinfo_unix_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTIMERINFO_UNIX_P_H
5#define QTIMERINFO_UNIX_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19
21
22#include <sys/time.h> // struct timespec
23#include <chrono>
24
26
27// internal timer info
29{
31 using TimePoint = std::chrono::time_point<std::chrono::steady_clock, Duration>;
36
37 TimePoint timeout = {}; // - when to actually fire
38 Duration interval = Duration{-1}; // - timer interval
39 Qt::TimerId id = Qt::TimerId::Invalid; // - timer identifier
40 Qt::TimerType timerType; // - timer type
41 QObject *obj = nullptr; // - object to receive event
42 QTimerInfo **activateRef = nullptr; // - ref from activateTimers
43};
44
45class Q_CORE_EXPORT QTimerInfoList
46{
47public:
51
52 mutable std::chrono::steady_clock::time_point currentTime;
53
54 std::optional<Duration> timerWait();
55 void timerInsert(QTimerInfo *);
56
57 Duration remainingDuration(Qt::TimerId timerId) const;
58
59 void registerTimer(Qt::TimerId timerId, Duration interval,
60 Qt::TimerType timerType, QObject *object);
61 bool unregisterTimer(Qt::TimerId timerId);
62 bool unregisterTimers(QObject *object);
63 QList<TimerInfo> registeredTimers(QObject *object) const;
64
65 int activateTimers();
66 bool hasPendingTimers();
67
69 {
70 qDeleteAll(timers);
71 timers.clear();
72 }
73
74 bool isEmpty() const { return timers.empty(); }
75
76 qsizetype size() const { return timers.size(); }
77
78 auto findTimerById(Qt::TimerId timerId) const
79 {
80 auto matchesId = [timerId](const auto &t) { return t->id == timerId; };
81 return std::find_if(timers.cbegin(), timers.cend(), matchesId);
82 }
83
84private:
85 std::chrono::steady_clock::time_point updateCurrentTime() const;
86
87 // state variables used by activateTimers()
88 QTimerInfo *firstTimerInfo = nullptr;
89 QList<QTimerInfo *> timers;
90};
91
93
94#endif // QTIMERINFO_UNIX_P_H
std::chrono::nanoseconds Duration
A {std::chrono::duration} type that is used in various API in this class.
\inmodule QtCore
Definition qobject.h:103
bool isEmpty() const
std::chrono::steady_clock::time_point currentTime
qsizetype size() const
QAbstractEventDispatcher::Duration Duration
auto findTimerById(Qt::TimerId timerId) const
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
TimerType
GLenum GLuint id
[7]
GLbitfield GLuint64 timeout
[4]
GLenum type
GLhandleARB obj
[2]
GLdouble GLdouble t
Definition qopenglext.h:243
ptrdiff_t qsizetype
Definition qtypes.h:165
\variable QAbstractEventDispatcher::TimerInfo::timerId
QTimerInfo ** activateRef
std::chrono::time_point< std::chrono::steady_clock, Duration > TimePoint
Duration interval
QAbstractEventDispatcher::Duration Duration
QTimerInfo(Qt::TimerId timerId, Duration interval, Qt::TimerType type, QObject *obj)
Qt::TimerType timerType