Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qautoresetevent_kqueue.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 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
5
6#include <QtCore/private/qcore_unix_p.h>
7#include <QtCore/qdebug.h>
8
10
11namespace QtPrivate {
12
14 QObject{
15 parent,
16 },
19 }
20{
21 m_kqueue = kqueue();
22 if (m_kqueue == -1) {
23 qCritical() << "kqueue failed:" << qt_error_string(errno);
24 return;
25 }
26
27 // Register a custom EVFILT_USER event with the EV_CLEAR flag.
28 // The EV_CLEAR flag causes the event to auto-reset once it is delivered.
29 EV_SET(&m_event, 1, EVFILT_USER, EV_ADD | EV_CLEAR, 0, 0, nullptr);
30 if (kevent(m_kqueue, &m_event, 1, nullptr, 0, nullptr) == -1) {
32 qCritical() << "Failed to register EVFILT_USER event:" << qt_error_string(errno);
33 return;
34 }
35
37 struct kevent ev;
38 int nev = kevent(m_kqueue, nullptr, 0, &ev, 1, nullptr);
39 if (nev > 0)
41 });
44}
45
51
53{
55
56 EV_SET(&m_event, 1, EVFILT_USER, 0, NOTE_TRIGGER, 0, nullptr);
57
58 if (kevent(m_kqueue, &m_event, 1, nullptr, 0, nullptr) == -1)
59 qWarning() << "Failed to signal event";
60}
61
63{
64 return m_kqueue != -1;
65}
66
67} // namespace QtPrivate
68
69QT_END_NAMESPACE
70
71#include "moc_qautoresetevent_kqueue_p.cpp"