Class OptimisticObjectLockManager.LockRemover<O,​L>

  • Type Parameters:
    O - The type of the objects to be locked (locked object type).
    L - The type of the objects that lock (lock owning type).
    All Implemented Interfaces:
    LockNotification<L>
    Enclosing class:
    OptimisticObjectLockManager<O,​L>

    protected static class OptimisticObjectLockManager.LockRemover<O,​L>
    extends Object
    implements LockNotification<L>
    When unlocking an object for the last time (count is 0), this will remove the corresponding locked object from the map containing all locked objects.
    Author:
    Ulrich Kreher
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected O lockedObject
      The locked object.
      protected Logger logger
      The logger for logging lock acquisitions and releasing - great for debugging purpose.
      protected ConcurrentMap<O,​ReentrantLock<L>> objectLocks
      A mapping from the locked object to the corresponding lock.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected LockRemover​(ConcurrentMap<O,​ReentrantLock<L>> objectLocks, O lockedObject, Logger logger)
      Creates a new remover for removing the lock from the internal map containing all locked objects.
    • Field Detail

      • logger

        protected final Logger logger
        The logger for logging lock acquisitions and releasing - great for debugging purpose.
      • lockedObject

        protected final O lockedObject
        The locked object.
    • Constructor Detail

      • LockRemover

        protected LockRemover​(ConcurrentMap<O,​ReentrantLock<L>> objectLocks,
                              O lockedObject,
                              Logger logger)
        Creates a new remover for removing the lock from the internal map containing all locked objects.
        Parameters:
        objectLocks - The mapping of the locked object to the corresponding lock from which to remove the lock after the last unlock.
        lockedObject - The locked object.
        logger - The logger for logging lock acquisitions and releasing - great for debugging purpose.
    • Method Detail

      • locked

        public void locked​(ReentrantLock<L> reLock,
                           boolean writeLock,
                           L lockingObject,
                           int lockCount)
        Description copied from interface: LockNotification
        Signals that the designated reentrant lock has been locked by the designated object for the designated number of times. Counting starts with 1.
        Specified by:
        locked in interface LockNotification<O>
        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

        public void unlocked​(ReentrantLock<L> reLock,
                             boolean writeLock,
                             boolean isLocked,
                             boolean waitersForLock,
                             L lockingObject,
                             int lockCount)
        Description copied from interface: LockNotification
        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).
        Specified by:
        unlocked in interface LockNotification<O>
        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.