Qt 4.8
|
The QLock class is a wrapper for a system shared semaphore. More...
#include <qlock_p.h>
Public Types | |
enum | Type { Read, Write } |
Public Functions | |
bool | isValid () const |
Returns true if the lock constructor was successful; returns false if the lock could not be created or was not available to connect to. More... | |
void | lock (Type type) |
Locks the semaphore with a lock of type t. More... | |
bool | locked () const |
Returns true if the lock is currently held by the current process; otherwise returns false. More... | |
QLock (const QString &filename, char id, bool create=false) | |
Creates a lock. More... | |
void | unlock () |
Unlocks the semaphore. More... | |
~QLock () | |
Destroys a lock. More... | |
Properties | |
QLockData * | data |
Type | type |
The QLock class is a wrapper for a system shared semaphore.
It is used by Qt for Embedded Linux for synchronizing access to the graphics card and shared memory region between processes.
enum QLock::Type |
QLock::QLock | ( | const QString & | filename, |
char | id, | ||
bool | create = false |
||
) |
Creates a lock.
filename is the file path of the Unix-domain socket the Qt for Embedded Linux client is using. id is the name of the particular lock to be created on that socket. If create is true the lock is to be created (as the Qt for Embedded Linux server does); if create is false the lock should exist already (as the Qt for Embedded Linux client expects).
Definition at line 158 of file qlock.cpp.
QLock::~QLock | ( | ) |
Destroys a lock.
Definition at line 221 of file qlock.cpp.
Referenced by QWSSignalHandler::clear().
bool QLock::isValid | ( | ) | const |
void QLock::lock | ( | Type | t | ) |
Locks the semaphore with a lock of type t.
Locks can either be Read
or Write
. If a lock is Read
, attempts by other processes to obtain Read
locks will succeed, and Write
attempts will block until the lock is unlocked. If locked as Write
, all attempts to lock by other processes will block until the lock is unlocked. Locks are stacked: i.e. a given QLock can be locked multiple times by the same process without blocking, and will only be unlocked after a corresponding number of unlock() calls.
Definition at line 285 of file qlock.cpp.
bool QLock::locked | ( | ) | const |
Returns true if the lock is currently held by the current process; otherwise returns false.
Definition at line 391 of file qlock.cpp.
void QLock::unlock | ( | ) |
Unlocks the semaphore.
If other processes were blocking waiting to lock() the semaphore, one of them will wake up and succeed in locking.
Definition at line 345 of file qlock.cpp.