A TReentrantLock
is a reentrant read/write lock. Multiple readers may all concurrently acquire read locks. Only one writer is allowed to acquire a write lock at any given time. Read locks may be upgraded into write locks. A fiber that has a write lock may acquire other write locks or read locks.
The two primary methods of this structure are readLock
, which acquires a read lock in a scoped context, and writeLock
, which acquires a write lock in a scoped context.
Although located in the STM package, there is no need for locks within STM transactions. However, this lock can be quite useful in effectful code, to provide consistent read/write access to mutable state; and being in STM allows this structure to be composed into more complicated concurrent structures that are consumed from effectful code.
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Retrieves the number of acquired read locks for this fiber.
Retrieves the number of acquired read locks for this fiber.
Attributes
Retrieves the number of acquired write locks for this fiber.
Retrieves the number of acquired write locks for this fiber.
Attributes
Just a convenience method for applications that only need reentrant locks, without needing a distinction between readers / writers.
Just a convenience method for applications that only need reentrant locks, without needing a distinction between readers / writers.
See writeLock.
Attributes
Determines if any fiber has a read or write lock.
Determines if any fiber has a read or write lock.
Attributes
Obtains a read lock in a scoped context.
Obtains a read lock in a scoped context.
Attributes
Determines if any fiber has a read lock.
Determines if any fiber has a read lock.
Attributes
Retrieves the total number of acquired read locks.
Retrieves the total number of acquired read locks.
Attributes
Runs the specified workflow with a lock.
Runs the specified workflow with a lock.
Attributes
Runs the specified workflow with a read lock.
Runs the specified workflow with a read lock.
Attributes
Runs the specified workflow with a write lock.
Runs the specified workflow with a write lock.
Attributes
Obtains a write lock in a scoped context.
Obtains a write lock in a scoped context.
Attributes
Determines if a write lock is held by some fiber.
Determines if a write lock is held by some fiber.
Attributes
Computes the number of write locks held by fibers.
Computes the number of write locks held by fibers.
Attributes
Concrete fields
Acquires a read lock. The transaction will suspend until no other fiber is holding a write lock. Succeeds with the number of read locks held by this fiber.
Acquires a read lock. The transaction will suspend until no other fiber is holding a write lock. Succeeds with the number of read locks held by this fiber.
Attributes
Acquires a write lock. The transaction will suspend until no other fibers are holding read or write locks. Succeeds with the number of write locks held by this fiber.
Acquires a write lock. The transaction will suspend until no other fibers are holding read or write locks. Succeeds with the number of write locks held by this fiber.
Attributes
Releases a read lock held by this fiber. Succeeds with the outstanding number of read locks held by this fiber.
Releases a read lock held by this fiber. Succeeds with the outstanding number of read locks held by this fiber.
Attributes
Releases a write lock held by this fiber. Succeeds with the outstanding number of write locks held by this fiber.
Releases a write lock held by this fiber. Succeeds with the outstanding number of write locks held by this fiber.