Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QReadWriteLock Class Reference

The QReadWriteLock class provides read-write locking. More...

#include <QReadWriteLock>

This class is under development and is subject to change.

Public Types

Public Functions


Detailed Description

The QReadWriteLock class provides read-write locking.

It is useful for synchronizing multithreaded access to resources that support multiple readers, but only one writer.

The lock is optimized for situations where there are many concurrent reads, and writing occurs infrequently. Writers are prioritized in front of readers, in the sense that readers attemting to optain the lock will yield to writers attemting to optain the lock.


Member Type Documentation

enum QReadWriteLock::AccessMode

This enum describes the different access types that a thread can specify when requesting the mutex.

QReadWriteLock::ReadAccessThe thread wants to perform read-operations.
QReadWriteLock::WriteAccessThe thread wants to perform write-operations.

Member Function Documentation

QReadWriteLock::QReadWriteLock ( const int maxReaders = INT_MAX )

Constructs a QReadWriteLock object allowing maxReaders concurrent readers. The default is INT_MAX.

See also lock().

QReadWriteLock::~QReadWriteLock ()

Destroys the QReadWriteMutex object.

Warning: If you destroy a read/write mutex that has accesses in use the resultant behavior is undefined.

void QReadWriteLock::lock ( AccessMode mode )

Attempts to lock the lock. This function will block the current thread if

See also unlock(), tryLock(), and ;.

bool QReadWriteLock::tryLock ( AccessMode mode )

Attempt to lock the lock. If the lock was obtained, this function returns true, otherwise it returns false instead of waiting for the lock to become available, i.e. it does not block.

The lock attempt will fail if one of the following is true:

If the lock was obtained, the lock must be unlocked with unlock() before another thread can successfully lock it.

See also unlock(), lock(), and ;.

void QReadWriteLock::unlock ()

Unlocks the lock.

Attempting to unlock a lock that i not locked is an error and will result in program termination.

See also lock(), trylock(), and ;.


Copyright © 2004 Trolltech Trademarks
Qt 4.0.0-b1