5#ifndef QSYSTEMSEMAPHORE_P_H
6#define QSYSTEMSEMAPHORE_P_H
21#if QT_CONFIG(systemsemaphore)
25#include "private/qtcore-config_p.h"
28#if QT_CONFIG(posix_sem)
29# include <semaphore.h>
32# define SEM_FAILED nullptr
35#if QT_CONFIG(sysv_sem)
41class QSystemSemaphorePrivate;
43struct QSystemSemaphorePosix
46 static bool supports(QNativeIpcKey::Type
type)
47 {
return type == QNativeIpcKey::Type::PosixRealtime; }
48 static bool runtimeSupportCheck();
50 bool handle(QSystemSemaphorePrivate *self, QSystemSemaphore::AccessMode
mode);
51 void cleanHandle(QSystemSemaphorePrivate *self);
52 bool modifySemaphore(QSystemSemaphorePrivate *self,
int count);
54 sem_t *semaphore = SEM_FAILED;
55 bool createdSemaphore =
false;
58struct QSystemSemaphoreSystemV
61 static bool supports(QNativeIpcKey::Type
type)
63 static bool runtimeSupportCheck();
65#if QT_CONFIG(sysv_sem)
66 key_t
handle(QSystemSemaphorePrivate *self, QSystemSemaphore::AccessMode
mode);
67 void cleanHandle(QSystemSemaphorePrivate *self);
68 bool modifySemaphore(QSystemSemaphorePrivate *self,
int count);
73 bool createdFile =
false;
74 bool createdSemaphore =
false;
78struct QSystemSemaphoreWin32
81 static constexpr bool Enabled =
true;
83 static constexpr bool Enabled =
false;
85 static bool supports(QNativeIpcKey::Type
type)
86 {
return type == QNativeIpcKey::Type::Windows; }
87 static bool runtimeSupportCheck() {
return Enabled; }
91 void cleanHandle(QSystemSemaphorePrivate *self);
92 bool modifySemaphore(QSystemSemaphorePrivate *self,
int count);
97class QSystemSemaphorePrivate
100 QSystemSemaphorePrivate(QNativeIpcKey::Type
type) : nativeKey(
type)
101 { constructBackend(); }
102 ~QSystemSemaphorePrivate() { destructBackend(); }
108 inline void clearError()
111 QNativeIpcKey nativeKey;
114 QSystemSemaphore::SystemSemaphoreError
error = QSystemSemaphore::NoError;
119 QSystemSemaphorePosix posix;
120 QSystemSemaphoreSystemV sysv;
121 QSystemSemaphoreWin32 win32;
123 QtIpcCommon::IpcStorageVariant<&Backend::posix, &Backend::sysv, &Backend::win32> backend;
125 void constructBackend();
126 void destructBackend();
128 template <
typename Lambda>
auto visit(
const Lambda &lambda)
130 return backend.visit(nativeKey.type(), lambda);
133 void handle(QSystemSemaphore::AccessMode
mode)
135 visit([&](
auto p) {
p->handle(
this,
mode); });
139 visit([&](
auto p) {
p->cleanHandle(
this); });
141 bool modifySemaphore(
int count)
143 return visit([&](
auto p) {
return p->modifySemaphore(
this,
count); });
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLuint64 GLenum void * handle
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * message
static void setError(QJsonObject *response, const QString &msg)
#define QT_CONFIG(feature)