RawReadWriteMutex class

A RawReadWriteMutex implementation that allows multiple readers or a single writer.

This mutex supports different lock policies to manage the order of lock acquisition:

  • LockPolicy.fair: Grants locks in the order they were requested.
  • LockPolicy.readersFirst: Prefers granting read locks over write locks.
  • LockPolicy.writersFirst: Prefers granting write locks over read locks.

Constructors

RawReadWriteMutex({LockPolicy lockPolicy = LockPolicy.fair})

Properties

hashCode → int
The hash code for this object.
no setterinherited
lockPolicy → LockPolicy
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

acquireRead({CancellationToken? cancellationToken, Duration? timeout}) → Future<void>
Acquires a read lock.
acquireWrite({CancellationToken? cancellationToken, Duration? timeout}) → Future<void>
Acquires a write lock.
isLocked() → bool
Checks if the mutex is currently locked (either read or write).
isReadLocked() → bool
Checks if the mutex is currently read-locked.
isWriteLocked() → bool
Checks if the mutex is currently write-locked.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
protectRead<T>(Future<T> action(), {CancellationToken? cancellationToken, Duration? timeout}) → Future<T>
Executes action within a read lock.
protectWrite<T>(Future<T> action(), {CancellationToken? cancellationToken, Duration? timeout}) → Future<T>
Executes action within a write lock.
releaseRead() → void
Releases a read lock.
releaseWrite() → void
Releases a write lock.
toString() → String
A string representation of this object.
inherited
tryAcquireWrite() → bool
Attempts to acquire a write lock without waiting.
tryLock<T>(Future<T> action(), {CancellationToken? cancellationToken, Duration? timeout}) → Future<T?>

Operators

operator ==(Object other) → bool
The equality operator.
inherited