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

## Interface ReadWriteLockManager

- All Known Implementing Classes:
    `AbstractReadWriteLockManager`, `ReadPrefReadWriteLockManager`, `StampedLockManager`, `WritePrefReadWriteLockManager`

      public interface ReadWriteLockManager

  A lock manager that manages a multi-read, single-write lock. This lock manager allows multiple read locks to be active at the same time. The write lock is exclusive, meaning that no other read- or write locks may be active at the same time.
  Author:
    Arjohn Kampman

- - ### Method Summary

    All Methods Instance Methods Abstract 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.

- - ### Method Detail

    - #### tryReadLock

          Lock tryReadLock()

      Gets a read lock, if available. This method will return null if the read lock is not immediately available.

    - #### getReadLock

          Lock getReadLock()
                    throws InterruptedException

      Gets a read lock. This method blocks until the read lock is available.
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.

    - #### tryWriteLock

          Lock tryWriteLock()

      Gets an exclusive write lock, if available. This method will return null if the write lock is not immediately available.

    - #### getWriteLock

          Lock getWriteLock()
                     throws InterruptedException

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

    - #### isWriterActive

          boolean isWriterActive()

      Returns `false` if there are no active write locks, otherwise returns `true`.

    - #### isReaderActive

          boolean isReaderActive()

      Returns `false` if there are no active read locks, otherwise returns `true`.

    - #### waitForActiveWriter

          void waitForActiveWriter()
                            throws InterruptedException

      Blocks until all write locks have been released.
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.

    - #### waitForActiveReaders

          void waitForActiveReaders()
                             throws InterruptedException

      Blocks until all read locks have been released.
      Throws:
        `InterruptedException` - In case the thread requesting the lock was `interrupted`.