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 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, the lock() will never block.

      Returns:
      true if the lock is available (or the timeout is expired), false otherwise.
    • 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 lock
      TimeoutException - if we are unable to acquire the lock after a specified timeout.
    • addListener

      void addListener(LockListener listener)
      Adds a LockListener to be invoked when the lock is available.

      The acquired parameter indicates that the lock is acquired (when it is true) or it timed out (when it is false).

      Parameters:
      listener - the LockListener to invoke.
    • toInvocationStage

      InvocationStage toInvocationStage()
      Returns:
      an InvocationStage for this lock.