Class Lock

  • All Implemented Interfaces:
    Latch, Control
    Direct Known Subclasses:
    ActiveLock

    class Lock
    extends java.lang.Object
    implements Latch, Control
    A Lock represents a granted or waiting lock request.
    MT - Mutable - Immutable identity : Thread Aware
    • Field Detail

      • space

        private final CompatibilitySpace space
        Compatibility space the object is locked in. MT - immutable - reference only
      • ref

        private final Lockable ref
        Object being locked. MT - immutable - reference only
      • qualifier

        private final java.lang.Object qualifier
        Qualifier used in the lock request.. MT - immutable - reference only
      • count

        int count
    • Method Detail

      • getQualifier

        public final java.lang.Object getQualifier()
        Return the qualifier lock was obtained with. MT - Thread safe
        Specified by:
        getQualifier in interface Latch
      • getCount

        public final int getCount()
        Return the count of locks. MT - Thread safe
        Specified by:
        getCount in interface Latch
      • copy

        final Lock copy()
      • grant

        void grant()
      • unlock

        int unlock​(int unlockCount)
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • shallowClone

        public Control shallowClone()
        We can return ourselves here because our identity is immutable and what we returned will not be accessed as a Lock, so the count cannot be changed.
        Specified by:
        shallowClone in interface Control
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Control
      • unlock

        public boolean unlock​(Latch lockInGroup,
                              int unlockCount)
        Specified by:
        unlock in interface Control
      • addWaiters

        public void addWaiters​(java.util.Map waiters)
        Specified by:
        addWaiters in interface Control
      • getGranted

        public java.util.List getGranted()
        Specified by:
        getGranted in interface Control
      • getWaiting

        public java.util.List getWaiting()
        Specified by:
        getWaiting in interface Control
      • isGrantable

        public boolean isGrantable​(boolean noWaitersBeforeMe,
                                   CompatibilitySpace compatibilitySpace,
                                   java.lang.Object requestQualifier)
        Specified by:
        isGrantable in interface Control