AsyncStampedLock
FairAsyncReadWriteLock
, FairAsyncStampedLock
public interface AsyncReadWriteLock
Implementations will specify whether their lock acquisition is fair or not; this interface does not define this requirement.
Modifier and Type | Interface | Description |
---|---|---|
static interface |
AsyncReadWriteLock.ReadLockToken |
A lock token indicating that the associated lock has been acquired for reader access.
|
static interface |
AsyncReadWriteLock.WriteLockToken |
A lock token indicating that the associated lock has been exclusively acquired for writer
access.
|
Modifier and Type | Method | Description |
---|---|---|
CompletionStage<AsyncReadWriteLock.ReadLockToken> |
acquireReadLock() |
Acquires this read lock.
|
CompletionStage<AsyncReadWriteLock.WriteLockToken> |
acquireWriteLock() |
Exclusively acquires this write lock.
|
static AsyncReadWriteLock |
create() |
Creates an
AsyncReadWriteLock |
static AsyncReadWriteLock |
createFair() |
Creates a fair
AsyncReadWriteLock |
Optional<AsyncReadWriteLock.ReadLockToken> |
tryReadLock() |
Attempts to immediately acquire the read lock, returning a populated
Optional if the
lock is not currently held by a writer. |
Optional<AsyncReadWriteLock.WriteLockToken> |
tryWriteLock() |
Attempts to immediately acquire the write lock, returning a populated
Optional if the
lock is not currently held by a writer or any readers. |
CompletionStage<AsyncReadWriteLock.ReadLockToken> acquireReadLock()
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.
CompletionStage
which will complete with a AsyncReadWriteLock.ReadLockToken
when the
read lock has been acquiredOptional<AsyncReadWriteLock.ReadLockToken> tryReadLock()
Optional
if the
lock is not currently held by a writer.
Implementations may define whether this attempt can succeed while a writer is waiting to acquire ("barging"). This interface only requires that the attempt will succeed if all writers have released and no new writers are acquiring.
Optional
holding a AsyncReadWriteLock.ReadLockToken
if the lock is not held by a
writer; otherwise an empty OptionalCompletionStage<AsyncReadWriteLock.WriteLockToken> acquireWriteLock()
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.
CompletionStage
which will complete with a AsyncReadWriteLock.WriteLockToken
when the
write lock has been exclusively acquiredOptional<AsyncReadWriteLock.WriteLockToken> tryWriteLock()
Optional
if the
lock is not currently held by a writer or any readers.Optional
holding a AsyncReadWriteLock.WriteLockToken
if the lock is not held by a
writer or any readers; otherwise an empty Optionalstatic AsyncReadWriteLock create()
AsyncReadWriteLock
The returned lock is only guaranteed to meet the requirements of AsyncReadWriteLock
; in
particular, no guarantee of fairness is provided.
AsyncReadWriteLock
static AsyncReadWriteLock createFair()
AsyncReadWriteLock
AsyncReadWriteLock
with a fair implementationCopyright © 2018. All rights reserved.