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
qohosdeadlockprotector.h
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#ifndef QOHOS_DEADLOCKPROTECTOR_H
5#define QOHOS_DEADLOCKPROTECTOR_H
6
7#include <QAtomicInt>
8
9QT_BEGIN_NAMESPACE
10
11class QOhosDeadlockProtector
12{
13public:
14 QOhosDeadlockProtector()
15 : m_acquired(0)
16 {
17 }
18
19 ~QOhosDeadlockProtector() {
20 if (m_acquired)
21 s_blocked.storeRelease(0);
22 }
23
24 bool acquire() {
25 m_acquired = s_blocked.testAndSetAcquire(0, 1);
26 return m_acquired;
27 }
28
29private:
30 static QAtomicInt s_blocked;
31 int m_acquired;
32};
33
34QT_END_NAMESPACE
35
36#endif // QOHOS_DEADLOCKPROTECTOR_H