Class AbstractReadWriteLockManager
java.lang.Object
org.eclipse.rdf4j.common.concurrent.locks.AbstractReadWriteLockManager
- All Implemented Interfaces:
ReadWriteLockManager
- Direct Known Subclasses:
ReadPrefReadWriteLockManager
,WritePrefReadWriteLockManager
An abstract base implementation of a read/write-lock manager.
- Author:
- HÃ¥vard M. Ottestad
-
Constructor Summary
ConstructorDescriptionAbstractReadWriteLockManager
(boolean trackLocks) AbstractReadWriteLockManager
(boolean trackLocks, int waitToCollect) AbstractReadWriteLockManager
(String alias, int waitToCollect, LockDiagnostics... lockDiagnostics) AbstractReadWriteLockManager
(String alias, LockDiagnostics... lockDiagnostics) -
Method Summary
Modifier and TypeMethodDescriptionGets a read lock.Gets an exclusive write lock.boolean
Returnsfalse
if there are no active read locks, otherwise returnstrue
.boolean
Returnsfalse
if there are no active write locks, otherwise returnstrue
.Gets a read lock, if available.Gets an exclusive write lock, if available.void
Blocks until all read locks have been released.void
Blocks until all write locks have been released.
-
Constructor Details
-
AbstractReadWriteLockManager
public AbstractReadWriteLockManager() -
AbstractReadWriteLockManager
public AbstractReadWriteLockManager(boolean trackLocks) -
AbstractReadWriteLockManager
public AbstractReadWriteLockManager(boolean trackLocks, int waitToCollect) -
AbstractReadWriteLockManager
-
AbstractReadWriteLockManager
public AbstractReadWriteLockManager(String alias, int waitToCollect, LockDiagnostics... lockDiagnostics)
-
-
Method Details
-
isWriterActive
public boolean isWriterActive()Returnsfalse
if there are no active write locks, otherwise returnstrue
.- Specified by:
isWriterActive
in interfaceReadWriteLockManager
-
isReaderActive
public boolean isReaderActive()Returnsfalse
if there are no active read locks, otherwise returnstrue
.- Specified by:
isReaderActive
in interfaceReadWriteLockManager
-
waitForActiveWriter
Blocks until all write locks have been released.- Specified by:
waitForActiveWriter
in interfaceReadWriteLockManager
- Throws:
InterruptedException
- In case the thread requesting the lock wasinterrupted
.
-
waitForActiveReaders
Blocks until all read locks have been released.- Specified by:
waitForActiveReaders
in interfaceReadWriteLockManager
- Throws:
InterruptedException
- In case the thread requesting the lock wasinterrupted
.
-
getReadLock
Gets a read lock. This method blocks until the read lock is available.- Specified by:
getReadLock
in interfaceReadWriteLockManager
- Throws:
InterruptedException
- In case the thread requesting the lock wasinterrupted
.
-
getWriteLock
Gets an exclusive write lock. This method blocks until the write lock is available.- Specified by:
getWriteLock
in interfaceReadWriteLockManager
- Throws:
InterruptedException
- In case the thread requesting the lock wasinterrupted
.
-
tryReadLock
Gets a read lock, if available. This method will return null if the read lock is not immediately available.- Specified by:
tryReadLock
in interfaceReadWriteLockManager
-
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 interfaceReadWriteLockManager
-