#include <qwslock_p.h>
|
bool | down (unsigned short semNum, int timeout) |
|
int | getValue (unsigned short semNum) const |
|
bool | up (unsigned short semNum) |
|
Definition at line 66 of file qwslock_p.h.
◆ LockType
Enumerator |
---|
BackingStore | |
Communication | |
RegionEvent | |
Definition at line 69 of file qwslock_p.h.
◆ QWSLock()
QWSLock::QWSLock |
( |
int |
lockId = -1 | ) |
|
Definition at line 78 of file qwslock.cpp.
80 static unsigned short initialValues[3] = { 1, 1, 0 };
82 #ifndef QT_NO_QWS_SIGNALHANDLER 88 semId = semget(IPC_PRIVATE, 3, IPC_CREAT | 0666);
90 perror(
"QWSLock::QWSLock");
91 qFatal(
"Unable to create semaphore");
95 semval.
array = initialValues;
96 if (semctl(
semId, 0, SETALL, semval) == -1) {
97 perror(
"QWSLock::QWSLock");
98 qFatal(
"Unable to initialize semaphores");
102 sems[0] = sems[1] = sems[2] = SEM_FAILED;
107 semId = (getpid() << 16) + (localUniqueId.fetchAndAddRelaxed(1) %
ushort(-1));
112 QByteArray keys[3] = { pfx +
"BackingStore", pfx +
"Communication", pfx +
"RegionEvent" };
113 for (
int i = 0; i < 3; ++i) {
115 sem_unlink(keys[i].constData());
117 sems[i] = sem_open(keys[i].constData(), (owned ?
O_CREAT : 0), 0666, initialValues[i]);
118 }
while (sems[i] == SEM_FAILED &&
errno == EINTR);
119 if (sems[i] == SEM_FAILED) {
120 perror(
"QWSLock::QWSLock");
121 qFatal(
"Unable to %s semaphore", (owned ?
"create" :
"open"));
The QByteArray class provides an array of bytes.
static QWSSignalHandler * instance()
Q_CORE_EXPORT void qFatal(const char *,...)
void addWSLock(QWSLock *wslock)
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
◆ ~QWSLock()
Definition at line 129 of file qwslock.cpp.
Referenced by QWSSignalHandler::clear().
131 #ifndef QT_NO_QWS_SIGNALHANDLER 139 semctl(
semId, 0, IPC_RMID, semval);
147 QByteArray keys[3] = { pfx +
"BackingStore", pfx +
"Communication", pfx +
"RegionEvent" };
148 for (
int i = 0; i < 3; ++i) {
149 if (sems[i] != SEM_FAILED) {
151 sems[i] = SEM_FAILED;
154 sem_unlink(keys[i].constData());
The QByteArray class provides an array of bytes.
void removeWSLock(QWSLock *wslock)
void unlock(LockType type)
static QWSSignalHandler * instance()
bool hasLock(LockType type)
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
◆ down()
bool QWSLock::down |
( |
unsigned short |
semNum, |
|
|
int |
timeout |
|
) |
| |
|
private |
Definition at line 185 of file qwslock.cpp.
Referenced by id(), lock(), unlock(), and wait().
190 sembuf sops = { semNum, -1, 0 };
196 sops.sem_flg |= SEM_UNDO;
#define EINTR_LOOP(var, cmd)
Q_CORE_EXPORT void qDebug(const char *,...)
◆ getValue()
int QWSLock::getValue |
( |
unsigned short |
semNum | ) |
const |
|
private |
Definition at line 210 of file qwslock.cpp.
Referenced by hasLock(), and id().
214 ret = semctl(
semId, semNum, GETVAL, 0);
216 if (sem_getvalue(sems[semNum], &ret) == -1)
220 qDebug(
"QWSLock::getValue(): %s", strerror(
errno));
Q_CORE_EXPORT void qDebug(const char *,...)
◆ hasLock()
◆ id()
int QWSLock::id |
( |
| ) |
const |
|
inline |
◆ lock()
bool QWSLock::lock |
( |
LockType |
type, |
|
|
int |
timeout = -1 |
|
) |
| |
Definition at line 224 of file qwslock.cpp.
bool down(unsigned short semNum, int timeout)
bool up(unsigned short semNum)
◆ unlock()
Definition at line 250 of file qwslock.cpp.
Referenced by wait(), and ~QWSLock().
bool down(unsigned short semNum, int timeout)
bool up(unsigned short semNum)
◆ up()
bool QWSLock::up |
( |
unsigned short |
semNum | ) |
|
|
private |
Definition at line 160 of file qwslock.cpp.
Referenced by id(), lock(), and unlock().
165 sembuf sops = { semNum, 1, 0 };
171 sops.sem_flg |= SEM_UNDO;
175 ret = sem_post(sems[semNum]);
#define EINTR_LOOP(var, cmd)
Q_CORE_EXPORT void qDebug(const char *,...)
◆ wait()
bool QWSLock::wait |
( |
LockType |
type, |
|
|
int |
timeout = -1 |
|
) |
| |
Definition at line 266 of file qwslock.cpp.
bool down(unsigned short semNum, int timeout)
void unlock(LockType type)
◆ lockCount
int QWSLock::lockCount[2] |
|
private |
◆ semId
The documentation for this class was generated from the following files: