ReadWriteMutex

This class represents a mutex that allows any number of readers to enter, but when a writer enters, all other readers and writers are blocked.

Please note that this mutex is not recursive and is intended to guard access to data only. Also, no deadlock checking is in place because doing so would require dynamic memory allocation, which would reduce performance by an unacceptable amount. As a result, any attempt to recursively acquire this mutex may well deadlock the caller, particularly if a write lock is acquired while holding a read lock, or vice-versa. In practice, this should not be an issue however, because it is uncommon to call deeply into unknown code while holding a lock that simply protects data.

Constructors

this
this(Policy policy)

Initializes a read/write mutex object with the supplied policy.

Members

Classes

Reader
class Reader

This class can be considered a mutex in its own right, and is used to negotiate a read lock for the enclosing mutex.

Writer
class Writer

This class can be considered a mutex in its own right, and is used to negotiate a write lock for the enclosing mutex.

Enums

Policy
enum Policy

Defines the policy used by this mutex. Currently, two policies are defined.

Functions

policy
Policy policy()

Gets the policy for the associated mutex.

Properties

reader
Reader reader [@property getter]

Gets an object representing the reader lock for the associated mutex.

writer
Writer writer [@property getter]

Gets an object representing the writer lock for the associated mutex.

Meta