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//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QAUTORESETEVENT_PIPE_P_H
16#define QAUTORESETEVENT_PIPE_P_H
17
18#include <QtCore/qsocketnotifier.h>
19#include <QtMultimedia/qtmultimediaexports.h>
20#include <atomic>
21
22QT_BEGIN_NAMESPACE
23
24namespace QtPrivate {
25
26class Q_MULTIMEDIA_EXPORT QAutoResetEventPipe final : public QObject
27{
28 Q_OBJECT
29
30public:
31 explicit QAutoResetEventPipe(QObject *parent = nullptr);
32 ~QAutoResetEventPipe();
33 Q_DISABLE_COPY_MOVE(QAutoResetEventPipe)
34
35 bool isValid() const { return m_fdProducer != -1; }
36
37 void set();
38
39 template <typename... Args>
40 QMetaObject::Connection callOnActivated(Args &&...args)
41 {
42 return connect(this, &QAutoResetEventPipe::activated, std::forward<Args>(args)...);
43 }
44
45 template <typename Functor>
46 QMetaObject::Connection callOnActivated(Functor &&functor)
47 {
48 return connect(this, &QAutoResetEventPipe::activated, this, std::forward<Functor>(functor));
49 }
50
51Q_SIGNALS:
52 void activated();
53
54private:
55 QSocketNotifier m_notifier;
56 int m_fdProducer = -1;
57 int m_fdConsumer = -1;
58 std::atomic_flag m_consumePending{};
59};
60
61} // namespace QtPrivate
62
63QT_END_NAMESPACE
64
65#endif // QAUTORESETEVENT_PIPE_P_H
66

source code of qtmultimedia/src/multimedia/audio/qautoresetevent_pipe_p.h