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
9
#
include
<
sys
/
eventfd
.
h
>
10
#
include
<
cstdint
>
11
12
QT_BEGIN_NAMESPACE
13
14
namespace
QtPrivate
{
15
16
QAutoResetEventEventFD
::
QAutoResetEventEventFD
(
QObject
*
parent
)
17
:
QObject
{
18
parent
,
19
},
20
m_notifier
{
21
QSocketNotifier
::
Type
::
Read
,
22
}
23
{
24
m_fd
=
eventfd
(
/*initval=*/
0, EFD_NONBLOCK);
25
if
(
m_fd
== -1) {
26
qCritical
() <<
"eventfd failed:"
<<
qt_error_string
(
errno
);
27
return
;
28
}
29
30
connect
(&
m_notifier
, &
QSocketNotifier
::
activated
,
this
, [
this
] {
31
uint64_t
payload
;
32
33
qt_safe_read
(
m_fd
, &
payload
,
sizeof
(
payload
));
34
35
emit
activated
();
36
});
37
m_notifier
.
setSocket
(
m_fd
);
38
m_notifier
.
setEnabled
(
true
);
39
}
40
41
QAutoResetEventEventFD
::~
QAutoResetEventEventFD
()
42
{
43
if
(
m_fd
!= -1)
44
qt_safe_close
(
m_fd
);
45
}
46
47
void
QAutoResetEventEventFD
::
set
()
48
{
49
Q_ASSERT
(
isValid
());
50
51
constexpr
uint64_t
increment
{ 1 };
52
53
qint64
bytesWritten
=
qt_safe_write
(
m_fd
, &
increment
,
sizeof
(
increment
));
54
if
(
bytesWritten
== -1)
55
qCritical
(
"QAutoResetEvent::set failed"
);
56
}
57
58
}
// namespace QtPrivate
59
60
QT_END_NAMESPACE
61
62
#
include
"moc_qautoresetevent_linux_p.cpp"
QtPrivate
Definition
qcompare.h:25
qtmultimedia
src
multimedia
audio
qautoresetevent_linux.cpp
Generated on Mon Mar 10 2025 00:50:43 for Qt by
1.13.2