Interface LockNotification<T>

  • Type Parameters:
    T - The type of objects which lock a reentrant lock (lock owning object type).
    All Known Implementing Classes:
    OptimisticObjectLockManager.LockRemover

    public interface LockNotification<T>
    This interface notifies about the state of ReentrantLocks. Notifications are sent after the state changed but still inside the atomic part when locking/unlocking. Therefore implementations must have a very short runtime.
    This notification is required for implementing lock mechanisms based on optimistic locking, for instance using ConcurrentHashMap.
    Author:
    Ulrich Kreher
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void locked​(ReentrantLock<T> reLock, boolean writeLock, T lockingObject, int lockCount)
      Signals that the designated reentrant lock has been locked by the designated object for the designated number of times.
      void unlocked​(ReentrantLock<T> reLock, boolean writeLock, boolean isLocked, boolean waitersForLock, T lockingObject, int lockCount)
      Signals that the designated reentrant lock has been unlocked and provides the number of times the lock is still held by the designated object.
    • Method Detail

      • locked

        void locked​(ReentrantLock<T> reLock,
                    boolean writeLock,
                    T lockingObject,
                    int lockCount)
        Signals that the designated reentrant lock has been locked by the designated object for the designated number of times. Counting starts with 1.
        Parameters:
        reLock - The lock which has been acquired (or rather is currently being acquired since the notification takes place while locking).
        writeLock - Whether the designated lock has been/is currently write locked. An exclusive lock is always write locked.
        lockingObject - The object which has acquired the lock for the designated number of times.
        lockCount - The number of times the lock the lock is currently being held by the current locking object. In case of a read lock there may be additional locks by other objects!
      • unlocked

        void unlocked​(ReentrantLock<T> reLock,
                      boolean writeLock,
                      boolean isLocked,
                      boolean waitersForLock,
                      T lockingObject,
                      int lockCount)
        Signals that the designated reentrant lock has been unlocked and provides the number of times the lock is still held by the designated object. The last unlocking will have 0. Additionally, it is provided whether there are waiters for the lock or other objects that have the lock (only possible for read locks).
        Parameters:
        reLock - The lock which has been released (or rather is currently being released since the notification takes place while unlocking).
        writeLock - Whether the designated lock has been/is currently unlocked from writing. An exclusive lock is always write locked.
        isLocked - Whether the designated lock is still being held by the designated locking object and/or by others.
        waitersForLock - Whether there are objects waiting for the designated lock.
        lockingObject - The object which has released the lock and still helds it for the designated number of times.
        lockCount - The number of times the lock the lock is still held by the designated locking object after the current unlocking.