Poco

class RWLock

Library: Foundation
Package: Threading
Header: Poco/RWLock.h

Description

A reader writer lock allows multiple concurrent readers or one exclusive writer.

Inheritance

Direct Base Classes: RWLockImpl

All Base Classes: RWLockImpl

Member Summary

Member Functions: readLock, tryReadLock, tryWriteLock, unlock, writeLock

Types Aliases

ScopedLock

using ScopedLock = ScopedRWLock;

ScopedReadLock

using ScopedReadLock = ScopedReadRWLock;

ScopedWriteLock

using ScopedWriteLock = ScopedWriteRWLock;

Constructors

RWLock

RWLock();

Creates the Reader/Writer lock.

Destructor

~RWLock

~RWLock();

Destroys the Reader/Writer lock.

Member Functions

readLock inline

void readLock();

Acquires a read lock. If another thread currently holds a write lock, waits until the write lock is released.

tryReadLock inline

bool tryReadLock();

Tries to acquire a read lock. Immediately returns true if successful, or false if another thread currently holds a write lock.

tryWriteLock inline

bool tryWriteLock();

Tries to acquire a write lock. Immediately returns true if successful, or false if one or more other threads currently hold locks. The result is undefined if the same thread already holds a read or write lock.

unlock inline

void unlock();

Releases the read or write lock.

writeLock inline

void writeLock();

Acquires a write lock. If one or more other threads currently hold locks, waits until all locks are released. The results are undefined if the same thread already holds a read or write lock