Interface LockPromise
- All Known Subinterfaces:
ExtendedLockPromise,KeyAwareLockPromise
public interface LockPromise
A promise returned by
InfinispanLock.
This promise does not means that the lock is acquired. The lock is acquired when the lock() method is
invoked. It contains the basic method to check it state (when it is available or not) and it allows adding listeners
to it.
- Since:
- 8.0
- Author:
- Pedro Ruivo
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(LockListener listener) Adds aLockListenerto be invoked when the lock is available.booleanIt tests if the lock is available.voidlock()It locks the key (or keys) associated to this promise.
-
Method Details
-
isAvailable
boolean isAvailable()It tests if the lock is available.The lock is consider available when it is successfully acquired or the timeout is expired. In any case, when it returns
true, thelock()will never block.- Returns:
trueif the lock is available (or the timeout is expired),falseotherwise.
-
lock
It locks the key (or keys) associated to this promise.This method will block until the lock is available or the timeout is expired.
- Throws:
InterruptedException- if the current thread is interrupted while acquiring the lockTimeoutException- if we are unable to acquire the lock after a specified timeout.
-
addListener
Adds aLockListenerto be invoked when the lock is available.The
acquiredparameter indicates that the lock is acquired (when it istrue) or it timed out (when it isfalse).- Parameters:
listener- theLockListenerto invoke.
-
toInvocationStage
InvocationStage toInvocationStage()- Returns:
- an
InvocationStagefor this lock.
-