Class RwAutoLock


  • public class RwAutoLock
    extends java.lang.Object
    Class wrapping a read-write lock mechanism that can be used with try-with-resources.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IAutoLock readunlock
      The resource read unlock.
      protected java.util.concurrent.locks.ReadWriteLock rwlock
      The internal lock.
      protected IAutoLock writeunlock
      The resource write unlock.
    • Constructor Summary

      Constructors 
      Constructor Description
      RwAutoLock()
      Creates the auto-lock.
      RwAutoLock​(java.util.concurrent.locks.ReadWriteLock lock)
      Creates the auto-lock.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.locks.ReadWriteLock getLock()
      Gets the internal lock.
      java.util.concurrent.locks.Lock getReadLock()
      Gets the read lock for manual locking.
      java.util.concurrent.locks.Lock getWriteLock()
      Gets the write lock for manual locking.
      IAutoLock readLock()
      Locks the read lock for resource-based locking.
      IAutoLock writeLock()
      Locks the write lock for resource-based locking.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rwlock

        protected java.util.concurrent.locks.ReadWriteLock rwlock
        The internal lock.
      • readunlock

        protected IAutoLock readunlock
        The resource read unlock.
      • writeunlock

        protected IAutoLock writeunlock
        The resource write unlock.
    • Constructor Detail

      • RwAutoLock

        public RwAutoLock()
        Creates the auto-lock.
      • RwAutoLock

        public RwAutoLock​(java.util.concurrent.locks.ReadWriteLock lock)
        Creates the auto-lock.
        Parameters:
        lock - Specific RW-lock to use internally.
    • Method Detail

      • readLock

        public IAutoLock readLock()
        Locks the read lock for resource-based locking.
      • writeLock

        public IAutoLock writeLock()
        Locks the write lock for resource-based locking.
      • getReadLock

        public java.util.concurrent.locks.Lock getReadLock()
        Gets the read lock for manual locking.
      • getWriteLock

        public java.util.concurrent.locks.Lock getWriteLock()
        Gets the write lock for manual locking.
      • getLock

        public java.util.concurrent.locks.ReadWriteLock getLock()
        Gets the internal lock.
        Returns:
        The lock.