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
qeventdispatcher_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 QEVENTDISPATCHER_UNIX_P_H
5#define QEVENTDISPATCHER_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/qabstracteventdispatcher.h"
19#include "QtCore/qlist.h"
20#include "private/qabstracteventdispatcher_p.h"
21#include "private/qcore_unix_p.h"
22#include "QtCore/qvarlengtharray.h"
23#include "QtCore/qhash.h"
24#include "private/qtimerinfo_unix_p.h"
25
27
29
30struct Q_CORE_EXPORT QSocketNotifierSetUNIX final
31{
32 inline QSocketNotifierSetUNIX() noexcept;
33
34 inline bool isEmpty() const noexcept;
35 inline short events() const noexcept;
36
37 QSocketNotifier *notifiers[3];
38};
39
41
43{
46
47 bool init();
48 pollfd prepare() const;
49
50 void wakeUp();
51 int check(const pollfd &pfd);
52
53 // note for eventfd(7) support:
54 // fds[0] stores the eventfd, fds[1] is unused
55 int fds[2] = { -1, -1 };
57
58#if defined(Q_OS_VXWORKS)
59 static constexpr int len_name = 20;
60 char name[len_name] = {};
61#endif
62};
63
65{
67 Q_DECLARE_PRIVATE(QEventDispatcherUNIX)
68
69public:
70 explicit QEventDispatcherUNIX(QObject *parent = nullptr);
72
73 bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
74
75 void registerSocketNotifier(QSocketNotifier *notifier) final;
76 void unregisterSocketNotifier(QSocketNotifier *notifier) final;
77
78 void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType,
79 QObject *object) override final;
80 bool unregisterTimer(Qt::TimerId timerId) override final;
81 bool unregisterTimers(QObject *object) override final;
82 QList<TimerInfoV2> timersForObject(QObject *object) const override final;
83 Duration remainingTime(Qt::TimerId timerId) const override final;
84
85 void wakeUp() override;
86 void interrupt() final;
87
88protected:
90};
91
93{
94 Q_DECLARE_PUBLIC(QEventDispatcherUNIX)
95
96public:
99
100 int activateTimers();
101
102 void markPendingSocketNotifiers();
103 int activateSocketNotifiers();
104 void setSocketNotifierPending(QSocketNotifier *notifier);
105
107 QList<pollfd> pollfds;
108
109 QHash<int, QSocketNotifierSetUNIX> socketNotifiers;
110 QList<QSocketNotifier *> pendingNotifiers;
111
114};
115
117{
118 notifiers[0] = nullptr;
119 notifiers[1] = nullptr;
120 notifiers[2] = nullptr;
121}
122
123inline bool QSocketNotifierSetUNIX::isEmpty() const noexcept
124{
125 return !notifiers[0] && !notifiers[1] && !notifiers[2];
126}
127
128inline short QSocketNotifierSetUNIX::events() const noexcept
129{
130 short result = 0;
131
132 if (notifiers[0])
133 result |= POLLIN;
134
135 if (notifiers[1])
136 result |= POLLOUT;
137
138 if (notifiers[2])
139 result |= POLLPRI;
140
141 return result;
142}
143
145
146#endif // QEVENTDISPATCHER_UNIX_P_H
DarwinBluetooth::LECBManagerNotifier * notifier
std::chrono::nanoseconds Duration
A {std::chrono::duration} type that is used in various API in this class.
\inmodule QtCore
Definition qatomic.h:112
QHash< int, QSocketNotifierSetUNIX > socketNotifiers
QList< QSocketNotifier * > pendingNotifiers
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
EGLint EGLint EGLint EGLint int int int int * fds
Combined button and popup list for selecting options.
TimerType
GLbitfield flags
GLuint name
GLuint64EXT * result
[6]
#define Q_OBJECT
@ Q_PRIMITIVE_TYPE
Definition qtypeinfo.h:157
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
QSocketNotifier * notifiers[3]
short events() const noexcept
bool isEmpty() const noexcept
int check(const pollfd &pfd)
pollfd prepare() const