Class MultiBinaryLongMap.PrimaryBinaryLongMap.ValidatingLock

  • All Implemented Interfaces:
    Lock
    Enclosing class:
    MultiBinaryLongMap.PrimaryBinaryLongMap

    protected class MultiBinaryLongMap.PrimaryBinaryLongMap.ValidatingLock
    extends Object
    implements Lock
    ValidatingLock is a Lock implementation specialized for the PrimaryBinaryLongMap that validates after every lock acquisition that the underlying BinaryLongMap implementation did not change.

    Note: ValidatingLock is assumed to be used by the PrimaryBinaryLongMap to wrap lock implementations that are dependent (chained) to the "master" RW-lock. As the master RW-lock is used to protect any structural changes, it also implicitly serves as a JMM memory barrier that guarantees a "flush" of the map implementation reference.

    • Field Detail

      • f_lock

        protected final Lock f_lock
        The underlying lock.
      • m_blmImpl

        protected BinaryLongMap m_blmImpl
        The primary BinaryLongMap implementation to check for
    • Constructor Detail

      • ValidatingLock

        public ValidatingLock​(Lock lock)
        Construct a ValidatingLock backed by the specified Lock.
        Parameters:
        lock - the underlying lock
      • ValidatingLock

        public ValidatingLock​(BinaryLongMap blm,
                              Lock lock)
        Construct a ValidatingLock backed by the specified Lock.
        Parameters:
        blm - the primary BinaryLongMap implementation to validate
        lock - the underlying lock
    • Method Detail

      • unlock

        public void unlock()
        Specified by:
        unlock in interface Lock
      • lock

        public void lock()
        Specified by:
        lock in interface Lock
      • tryLock

        public boolean tryLock()
        Specified by:
        tryLock in interface Lock
      • getImplMap

        protected BinaryLongMap getImplMap()
        Return the primary BinaryLongMap implementation validate by this ValidatingLock.
        Returns:
        the primary BinaryLongMap implementation validated by this ValidatingLock
      • setImplMap

        protected void setImplMap​(BinaryLongMap blmImpl)
        Set the primary BinaryLongMap implementation to be validated by this ValidatingLock.
        Parameters:
        blmImpl - the primary BinaryLongMap implementation
      • validate

        protected void validate()
        Validate that the BinaryLongMap associated with this ValidatingLock is still the implementation map of the containing PrimaryBinaryLongMap.

        Callers are required to hold the lock. Note: the lock provides a memory barrier ensuring visibility of updates to the map implementation of the outer PrimaryBinaryLongMap.