FairAsyncLock
public interface AsyncLock
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 |
AsyncLock.LockToken |
A lock token indicating that the associated lock has been exclusively acquired.
|
Modifier and Type | Method | Description |
---|---|---|
CompletionStage<AsyncLock.LockToken> |
acquireLock() |
Exclusively acquires this lock.
|
static AsyncLock |
create() |
Creates an
AsyncLock |
static AsyncLock |
createFair() |
Creates a fair
AsyncLock |
Optional<AsyncLock.LockToken> |
tryLock() |
Attempts to immediately acquire the lock, returning a populated
Optional if the lock is
not currently held. |
CompletionStage<AsyncLock.LockToken> acquireLock()
The AsyncLock.LockToken
held by the returned stage is used to release the lock after it has been
acquired and the lock-protected action has completed.
CompletionStage
which will complete with a AsyncLock.LockToken
when the lock
has been exclusively acquiredOptional<AsyncLock.LockToken> tryLock()
Optional
if the lock is
not currently held.Optional
holding a AsyncLock.LockToken
if the lock is not held; otherwise an
empty Optionalstatic AsyncLock create()
AsyncLock
The returned lock is only guaranteed to meet the requirements of AsyncLock
; in
particular, no guarantee of fairness is provided.
AsyncLock
Copyright © 2018. All rights reserved.