Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsystemsemaphore.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QSYSTEMSEMAPHORE_H
5#define QSYSTEMSEMAPHORE_H
6
7#include <QtCore/qcoreapplication.h>
8#include <QtCore/qtipccommon.h>
9#include <QtCore/qstring.h>
10#include <QtCore/qscopedpointer.h>
11
13
14#if QT_CONFIG(systemsemaphore)
15
16class QSystemSemaphorePrivate;
17
18class Q_CORE_EXPORT QSystemSemaphore
19{
21 Q_DECLARE_TR_FUNCTIONS(QSystemSemaphore)
22public:
23 enum AccessMode
24 {
25 Open,
26 Create
27 };
28 Q_ENUM(AccessMode)
29
30 enum SystemSemaphoreError
31 {
32 NoError,
33 PermissionDenied,
34 KeyError,
35 AlreadyExists,
36 NotFound,
37 OutOfResources,
38 UnknownError
39 };
40
41 QSystemSemaphore(const QNativeIpcKey &key, int initialValue = 0, AccessMode = Open);
42 ~QSystemSemaphore();
43
44 void setNativeKey(const QNativeIpcKey &key, int initialValue = 0, AccessMode = Open);
45 void setNativeKey(const QString &key, int initialValue = 0, AccessMode mode = Open,
46 QNativeIpcKey::Type type = QNativeIpcKey::legacyDefaultTypeForOs())
47 { setNativeKey({ key, type }, initialValue, mode); }
48 QNativeIpcKey nativeIpcKey() const;
49
50 QSystemSemaphore(const QString &key, int initialValue = 0, AccessMode mode = Open);
51 void setKey(const QString &key, int initialValue = 0, AccessMode mode = Open);
52 QString key() const;
53
54 bool acquire();
55 bool release(int n = 1);
56
57 SystemSemaphoreError error() const;
58 QString errorString() const;
59
60 static bool isKeyTypeSupported(QNativeIpcKey::Type type) Q_DECL_CONST_FUNCTION;
61 static QNativeIpcKey platformSafeKey(const QString &key,
62 QNativeIpcKey::Type type = QNativeIpcKey::DefaultTypeForOs);
63 static QNativeIpcKey legacyNativeKey(const QString &key,
64 QNativeIpcKey::Type type = QNativeIpcKey::legacyDefaultTypeForOs());
65
66private:
67 Q_DISABLE_COPY(QSystemSemaphore)
68 QScopedPointer<QSystemSemaphorePrivate> d;
69};
70
71#endif // QT_CONFIG(systemsemaphore)
72
74
75#endif // QSYSTEMSEMAPHORE_H
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
Q_MULTIMEDIA_EXPORT QString errorString(HRESULT hr)
#define Q_DECL_CONST_FUNCTION
#define Q_DECLARE_TR_FUNCTIONS(context)
DBusConnection const char DBusError * error
GLenum mode
GLuint64 key
GLenum type
GLfloat n
@ NoError
Definition main.cpp:34
#define Q_ENUM(x)
#define Q_GADGET
sem acquire()
sem release()
setKey(0)
[0]