Class ReadWriteLockHolder

    • Constructor Detail

      • ReadWriteLockHolder

        public ReadWriteLockHolder()
        Default constructor for serialization interfaces
    • Method Detail

      • isWriteLocked

        public boolean isWriteLocked()
        Return true if this lock is currently owned exclusively by anyone.
        Returns:
        true if this lock is currently owned exclusively by anyone
      • isReadLocked

        public boolean isReadLocked()
        Return true if this lock is currently locked for reads by one or more threads.
        Returns:
        true if this lock is currently locked for reads by anyone
      • isLocked

        public boolean isLocked()
        Return true if this lock is currently locked for reads or writes by anyone.
        Returns:
        true if this lock is currently locked for reads or writes by anyone
      • isWriteLockedBy

        public boolean isWriteLockedBy​(LockOwner owner)
        Return true if this lock is currently owned exclusively by the specified owner.
        Parameters:
        owner - the lock owner to check
        Returns:
        true if this lock is currently owned exclusively by the specified owner
      • isWriteLockedByMember

        public boolean isWriteLockedByMember​(UID memberId)
        Return true if this lock is currently owned exclusively by the specified member, regardless of which thread on that member owns it.
        Parameters:
        memberId - the ID of the member to check
        Returns:
        true if this lock is currently owned exclusively by the specified member
      • isReadLockedBy

        public boolean isReadLockedBy​(LockOwner owner)
        Return true if this lock is currently locked for reads by the specified owner.
        Parameters:
        owner - the lock owner to check
        Returns:
        true if this lock is currently locked for reads by the specified owner
      • isReadLockedByMember

        public boolean isReadLockedByMember​(UID memberId)
        Return true if this lock is currently locked for reads by the specified member, regardless of which thread on that member locked it.
        Parameters:
        memberId - the ID of the member to check
        Returns:
        true if this lock is currently locked for reads by the specified member
      • isLockedBy

        public boolean isLockedBy​(LockOwner owner)
        Return true if this lock is currently locked for reads by the specified owner.
        Parameters:
        owner - the lock owner to check
        Returns:
        true if this lock is currently locked for reads by the specified owner
      • isLockedByMember

        public boolean isLockedByMember​(UID memberId)
        Return true if this lock is currently locked for either reads or writes by the specified member, regardless of which thread on that member locked it.
        Parameters:
        memberId - the ID of the member to check
        Returns:
        true if this lock is currently locked for either reads or writes by the specified member
      • lockWrite

        public boolean lockWrite​(LockOwner owner)
        Attempt to obtain write lock, and return true if successful.
        Parameters:
        owner - the lock owner to obtain the lock for
        Returns:
        true if the lock was successfully obtained
      • unlockWrite

        public boolean unlockWrite​(LockOwner owner)
        Release write lock, and return true if successful.
        Parameters:
        owner - the lock owner to release the lock for
        Returns:
        true if the lock was successfully released
      • lockRead

        public boolean lockRead​(LockOwner owner)
        Attempt to obtain read lock, and return true if successful.
        Parameters:
        owner - the lock owner to obtain the lock for
        Returns:
        true if the lock was successfully obtained
      • unlockRead

        public boolean unlockRead​(LockOwner owner)
        Release read lock, and return true if successful.
        Parameters:
        owner - the lock owner to release the lock for
        Returns:
        true if the lock was successfully released
      • getWriteLock

        public LockOwner getWriteLock()
        Return the owner of a write lock, if any.
        Returns:
        the owner of a write lock, if any; null otherwise
      • getReadLocks

        public Set<? extends LockOwner> getReadLocks()
        Return the set of read lock owners.
        Returns:
        the set of read lock owners; could be empty
      • getReadLockCount

        public int getReadLockCount()
        Return the count of active read locks.
        Returns:
        the count of active read locks
      • removeLocksFor

        protected boolean removeLocksFor​(UID memberId)
        Remove all the locks that are owned by a specified member.
        Parameters:
        memberId - the UID of a member to remove the locks for
        Returns:
        true if this holder was modified
      • retainLocksFor

        protected boolean retainLocksFor​(Set<UID> setMemberIds)
        Remove all the locks that are NOT owned by one of the specified members.
        Parameters:
        setMemberIds - the UIDs of the valid members to retain the locks for
        Returns:
        true if this holder was modified