Interface LockPromise
-
- All Known Subinterfaces:
ExtendedLockPromise
,KeyAwareLockPromise
public interface LockPromise
A 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 void
addListener(LockListener listener)
Adds aLockListener
to be invoked when the lock is available.boolean
isAvailable()
It tests if the lock is available.void
lock()
It locks the key (or keys) associated to this promise.InvocationStage
toInvocationStage()
-
-
-
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:
true
if the lock is available (or the timeout is expired),false
otherwise.
-
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 aLockListener
to be invoked when the lock is available.The
acquired
parameter indicates that the lock is acquired (when it istrue
) or it timed out (when it isfalse
).- Parameters:
listener
- theLockListener
to invoke.
-
toInvocationStage
InvocationStage toInvocationStage()
- Returns:
- an
InvocationStage
for this lock.
-
-