Class ClientRWLock

  • All Implemented Interfaces:
    java.util.concurrent.locks.ReadWriteLock

    @ThreadSafe
    public final class ClientRWLock
    extends java.lang.Object
    implements java.util.concurrent.locks.ReadWriteLock
    Read/write lock associated with clients rather than threads. Either its read lock or write lock can be released by a thread different from the one acquiring them (but supposed to be requested by the same client).
    • Constructor Detail

      • ClientRWLock

        public ClientRWLock​(int maxReaders)
        Constructs a new ClientRWLock.
        Parameters:
        maxReaders - total number of permits, decides the max number of concurrent readers
    • Method Detail

      • readLock

        public java.util.concurrent.locks.Lock readLock()
        Specified by:
        readLock in interface java.util.concurrent.locks.ReadWriteLock
      • writeLock

        public java.util.concurrent.locks.Lock writeLock()
        Specified by:
        writeLock in interface java.util.concurrent.locks.ReadWriteLock
      • getReferenceCount

        public int getReferenceCount()
        Returns:
        the reference count
      • addReference

        public void addReference()
        Increments the reference count.
      • dropReference

        public int dropReference()
        Decrements the reference count.
        Returns:
        the new reference count