Package org.eclipse.rdf4j.common.concurrent.locks

## Class AbstractReadWriteLockManager

- java.lang.Object
- - org.eclipse.rdf4j.common.concurrent.locks.AbstractReadWriteLockManager

- All Implemented Interfaces:
    `ReadWriteLockManager`
  Direct Known Subclasses:
    `ReadPrefReadWriteLockManager`, `WritePrefReadWriteLockManager`

      public abstract class AbstractReadWriteLockManager
      extends Object
      implements ReadWriteLockManager

  An abstract base implementation of a read/write-lock manager.
  Author:
    Håvard M. Ottestad

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractReadWriteLockManager()` |
    `AbstractReadWriteLockManager​(boolean trackLocks)` |
    `AbstractReadWriteLockManager​(boolean trackLocks, int waitToCollect)` |
    `AbstractReadWriteLockManager​(String alias, int waitToCollect, LockDiagnostics... lockDiagnostics)` |
    `AbstractReadWriteLockManager​(String alias, LockDiagnostics... lockDiagnostics)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Lock` | `getReadLock()` | Gets a read lock.
    `Lock` | `getWriteLock()` | Gets an exclusive write lock.
    `boolean` | `isReaderActive()` | Returns `false` if there are no active read locks, otherwise returns `true`.
    `boolean` | `isWriterActive()` | Returns `false` if there are no active write locks, otherwise returns `true`.
    `Lock` | `tryReadLock()` | Gets a read lock, if available.
    `Lock` | `tryWriteLock()` | Gets an exclusive write lock, if available.
    `void` | `waitForActiveReaders()` | Blocks until all read locks have been released.
    `void` | `waitForActiveWriter()` | Blocks until all write locks have been released.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractReadWriteLockManager

          public AbstractReadWriteLockManager()

    - #### AbstractReadWriteLockManager

          public AbstractReadWriteLockManager​(boolean trackLocks)

    - #### AbstractReadWriteLockManager

          public AbstractReadWriteLockManager​(boolean trackLocks,
                                              int waitToCollect)

    - #### AbstractReadWriteLockManager

          public AbstractReadWriteLockManager​(String alias,
                                              LockDiagnostics... lockDiagnostics)

    - #### AbstractReadWriteLockManager

          public AbstractReadWriteLockManager​(String alias,
                                              int waitToCollect,
                                              LockDiagnostics... lockDiagnostics)

  - ### Method Detail

    - #### isWriterActive

          public boolean isWriterActive()

      Returns `false` if there are no active write locks, otherwise returns `true`.
      Specified by:
        `isWriterActive` in interface `ReadWriteLockManager`

    - #### isReaderActive

          public boolean isReaderActive()

      Returns `false` if there are no active read locks, otherwise returns `true`.
      Specified by:
        `isReaderActive` in interface `ReadWriteLockManager`

    - #### waitForActiveWriter

          public void waitForActiveWriter()
                                   throws InterruptedException

      Blocks until all write locks have been released.
      Specified by:
        `waitForActiveWriter` in interface `ReadWriteLockManager`
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.

    - #### waitForActiveReaders

          public void waitForActiveReaders()
                                    throws InterruptedException

      Blocks until all read locks have been released.
      Specified by:
        `waitForActiveReaders` in interface `ReadWriteLockManager`
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.

    - #### getReadLock

          public Lock getReadLock()
                           throws InterruptedException

      Gets a read lock. This method blocks until the read lock is available.
      Specified by:
        `getReadLock` in interface `ReadWriteLockManager`
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.

    - #### getWriteLock

          public Lock getWriteLock()
                            throws InterruptedException

      Gets an exclusive write lock. This method blocks until the write lock is available.
      Specified by:
        `getWriteLock` in interface `ReadWriteLockManager`
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.

    - #### tryReadLock

          public Lock tryReadLock()

      Gets a read lock, if available. This method will return null if the read lock is not immediately available.
      Specified by:
        `tryReadLock` in interface `ReadWriteLockManager`

    - #### tryWriteLock

          public Lock tryWriteLock()

      Gets an exclusive write lock, if available. This method will return null if the write lock is not immediately available.
      Specified by:
        `tryWriteLock` in interface `ReadWriteLockManager`