Interface LockPromise
-
- All Known Subinterfaces:
ExtendedLockPromise,KeyAwareLockPromise
public interface LockPromiseA promise returned byInfinispanLock.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(LockListener listener)Adds aLockListenerto be invoked when the lock is available.booleanisAvailable()It tests if the lock is available.voidlock()It locks the key (or keys) associated to this promise.InvocationStagetoInvocationStage()
-
-
-
Method Detail
-
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
void lock() throws InterruptedException, TimeoutException
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
void addListener(LockListener listener)
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.
-
-