T - the type of named objects used to identify read-write locksFairAsyncNamedReadWriteLockpublic interface AsyncNamedReadWriteLock<T>
object equality. Acquisitions of different names may proceed
unobstructed.
Implementations will specify whether their lock acquisition is fair or not; this interface does not define this requirement.
Note that implementations will generally employ an underlying Map; as such, the
same precautions must be taken regarding mutability of keys (names). Name objects should not
change from the time of acquisition to the time of release, with respect to their
equality and hash code semantics. The
release methods of the returned AsyncReadWriteLock.ReadLockToken and
AsyncReadWriteLock.WriteLockToken may throw a
ConcurrentModificationException if such a modification is detected.
| Modifier and Type | Method | Description |
|---|---|---|
CompletionStage<AsyncReadWriteLock.ReadLockToken> |
acquireReadLock(T name) |
Acquires the read lock associated with the given name.
|
CompletionStage<AsyncReadWriteLock.WriteLockToken> |
acquireWriteLock(T name) |
Exclusively acquires the write lock associated with the given name.
|
static <T> AsyncNamedReadWriteLock<T> |
create() |
Creates an
AsyncNamedReadWriteLock |
static <T> AsyncNamedReadWriteLock<T> |
createFair() |
Creates a fair
AsyncNamedReadWriteLock |
Optional<AsyncReadWriteLock.ReadLockToken> |
tryReadLock(T name) |
Attempts to acquire the read lock associated with the given name.
|
Optional<AsyncReadWriteLock.WriteLockToken> |
tryWriteLock(T name) |
Attempts to acquire the write lock associated with the given name.
|
CompletionStage<AsyncReadWriteLock.ReadLockToken> acquireReadLock(T name)
The AsyncReadWriteLock.ReadLockToken held by the returned stage is used to release the
read lock after it has been acquired and the read-lock-protected action has completed.
name - to acquire read access forCompletionStage which will complete with a
AsyncReadWriteLock.ReadLockToken when the read lock associated with
name has been acquiredCompletionStage<AsyncReadWriteLock.WriteLockToken> acquireWriteLock(T name)
The AsyncReadWriteLock.WriteLockToken held by the returned stage is used to release the
write lock after it has been acquired and the write-lock-protected action has completed.
name - to acquire exclusive write access forCompletionStage which will complete with a
AsyncReadWriteLock.WriteLockToken when the lock associated with name
has been exclusively acquiredOptional<AsyncReadWriteLock.ReadLockToken> tryReadLock(T name)
The AsyncReadWriteLock.ReadLockToken held by the returned optional is used to release
the read lock after it has been acquired and the read-lock-protected action has completed.
name - to acquire read access forOptional holding a AsyncReadWriteLock.ReadLockToken if the write
lock associated with name is not held; otherwise an empty OptionalOptional<AsyncReadWriteLock.WriteLockToken> tryWriteLock(T name)
The AsyncReadWriteLock.WriteLockToken held by the returned optional is used to release
the write lock after it has been acquired and the write-lock-protected action has completed.
name - to acquire exclusive write access forOptional holding a AsyncReadWriteLock.WriteLockToken if the lock
associated with name is not held by a writer or any readers; otherwise an empty
Optionalstatic <T> AsyncNamedReadWriteLock<T> create()
AsyncNamedReadWriteLock
The returned lock is only guaranteed to meet the requirements of
AsyncNamedReadWriteLock; in particular, no guarantee of fairness is provided.
AsyncNamedReadWriteLockstatic <T> AsyncNamedReadWriteLock<T> createFair()
AsyncNamedReadWriteLockAsyncNamedReadWriteLock with a fair implementationCopyright © 2018. All rights reserved.