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_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
<
QtCore
/
private
/
qcore_unix_p
.
h
>
7
#
include
<
QtCore
/
qdebug
.
h
>
8
#
include
<
QtMultimedia
/
private
/
qaudio_rtsan_support_p
.
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_notifier
{
22
QSocketNotifier
::
Type
::
Read
,
23
}
24
{
25
m_fd
=
eventfd
(
/*initval=*/
0, EFD_NONBLOCK);
26
if
(
m_fd
== -1) {
27
qCritical
() <<
"eventfd failed:"
<<
qt_error_string
(
errno
);
28
return
;
29
}
30
31
connect
(&
m_notifier
, &
QSocketNotifier
::
activated
,
this
, [
this
] {
32
uint64_t
payload
;
33
34
qt_safe_read
(
m_fd
, &
payload
,
sizeof
(
payload
));
35
36
emit
activated
();
37
});
38
m_notifier
.
setSocket
(
m_fd
);
39
m_notifier
.
setEnabled
(
true
);
40
}
41
42
QAutoResetEventEventFD
::~
QAutoResetEventEventFD
()
43
{
44
if
(
m_fd
!= -1)
45
qt_safe_close
(
m_fd
);
46
}
47
48
void
QAutoResetEventEventFD
::
set
()
49
{
50
Q_ASSERT
(
isValid
());
51
52
constexpr
uint64_t
increment
{ 1 };
53
54
ScopedRTSanDisabler
disabler
;
// opened via EFD_NONBLOCK
55
qint64
bytesWritten
=
qt_safe_write
(
m_fd
, &
increment
,
sizeof
(
increment
));
56
if
(
bytesWritten
== -1)
57
qCritical
(
"QAutoResetEvent::set failed"
);
58
}
59
60
}
// namespace QtPrivate
61
62
QT_END_NAMESPACE
63
64
#
include
"moc_qautoresetevent_linux_p.cpp"
QtPrivate
Definition
qalloc.h:27
qtmultimedia
src
multimedia
audio
qautoresetevent_linux.cpp
Generated on
for Qt by
1.14.0