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_linux.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 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_linux_p.h"
5
6
#
include
<
QtMultimedia
/
private
/
qtmm_rtsan_support_p
.
h
>
7
#
include
<
QtCore
/
private
/
qcore_unix_p
.
h
>
8
#
include
<
QtCore
/
qdebug
.
h
>
9
10
#
include
<
sys
/
eventfd
.
h
>
11
#
include
<
cstdint
>
12
13
QT_BEGIN_NAMESPACE
14
15
namespace
QtPrivate
{
16
17
QAutoResetEventEventFD
::
QAutoResetEventEventFD
(
QObject
*
parent
)
18
:
QObject
{
19
parent
,
20
},
21
m_fd
{
22
eventfd
(
/*initval=*/
0, EFD_NONBLOCK),
23
},
24
m_notifier
{
25
QSocketNotifier
::
Type
::
Read
,
26
this
,
27
}
28
{
29
if
(!
isValid
()) {
30
qCritical
() <<
"eventfd failed:"
<<
qt_error_string
(
errno
);
31
return
;
32
}
33
34
connect
(&
m_notifier
, &
QSocketNotifier
::
activated
,
this
, [
this
] {
35
uint64_t
payload
;
36
37
std
::
ignore
=
qt_safe_read
(
m_fd
.
get
(), &
payload
,
sizeof
(
payload
));
38
39
Q_EMIT
activated
();
40
});
41
m_notifier
.
setSocket
(
m_fd
.
get
());
42
m_notifier
.
setEnabled
(
true
);
43
}
44
45
void
QAutoResetEventEventFD
::
set
()
46
{
47
Q_ASSERT
(
isValid
());
48
49
constexpr
uint64_t
increment
{ 1 };
50
51
ScopedRTSanDisabler
disabler
;
// opened via EFD_NONBLOCK
52
qint64
bytesWritten
=
qt_safe_write
(
m_fd
.
get
(), &
increment
,
sizeof
(
increment
));
53
if
(
bytesWritten
== -1)
54
qCritical
(
"QAutoResetEvent::set failed"
);
55
}
56
57
}
// namespace QtPrivate
58
59
QT_END_NAMESPACE
60
61
#
include
"moc_qautoresetevent_linux_p.cpp"
QtPrivate
Definition
qalloc.h:29
qtmultimedia
src
multimedia
support
qautoresetevent_linux.cpp
Generated on
for Qt by
1.18.0