Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
4
#
include
"qautoresetevent_kqueue_p.h"
5
6
#
include
<
QtCore
/
private
/
qcore_unix_p
.
h
>
7
#
include
<
QtCore
/
qdebug
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
namespace
QtPrivate
{
12
13
QAutoResetEventKQueue
::
QAutoResetEventKQueue
(
QObject
*
parent
)
14
:
QObject
{
15
parent
,
16
},
17
m_kqueue
{
18
kqueue
(),
19
},
20
m_notifier
{
21
QSocketNotifier
::
Type
::
Read
,
22
this
,
23
}
24
{
25
if
(!
isValid
()) {
26
qCritical
() <<
"kqueue failed:"
<<
qt_error_string
(
errno
);
27
return
;
28
}
29
30
// Register a custom EVFILT_USER event with the EV_CLEAR flag.
31
// The EV_CLEAR flag causes the event to auto-reset once it is delivered.
32
EV_SET
(&
m_event
, 1,
EVFILT_USER
,
EV_ADD
|
EV_CLEAR
, 0, 0,
nullptr
);
33
if
(
kevent
(
m_kqueue
.
get
(), &
m_event
, 1,
nullptr
, 0,
nullptr
) == -1) {
34
qCritical
() <<
"Failed to register EVFILT_USER event:"
<<
qt_error_string
(
errno
);
35
m_kqueue
.
reset
();
36
return
;
37
}
38
39
connect
(&
m_notifier
, &
QSocketNotifier
::
activated
,
this
, [
this
] {
40
struct
kevent
ev
;
41
int
nev
=
kevent
(
m_kqueue
.
get
(),
nullptr
, 0, &
ev
, 1,
nullptr
);
42
if
(
nev
> 0)
43
Q_EMIT
activated
();
44
});
45
m_notifier
.
setSocket
(
m_kqueue
.
get
());
46
m_notifier
.
setEnabled
(
true
);
47
}
48
49
void
QAutoResetEventKQueue
::
set
()
50
{
51
Q_ASSERT
(
isValid
());
52
53
EV_SET
(&
m_event
, 1,
EVFILT_USER
, 0,
NOTE_TRIGGER
, 0,
nullptr
);
54
55
if
(
kevent
(
m_kqueue
.
get
(), &
m_event
, 1,
nullptr
, 0,
nullptr
) == -1)
56
qWarning
() <<
"Failed to signal event"
;
57
}
58
59
}
// namespace QtPrivate
60
61
QT_END_NAMESPACE
62
63
#
include
"moc_qautoresetevent_kqueue_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtPrivate
Definition
qalloc.h:29
qtmultimedia
src
multimedia
support
qautoresetevent_kqueue.cpp
Generated on
for Qt by
1.18.0