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
ConstructorsConstructorDescriptionAbstractReadWriteLockManager(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.booleanReturnsfalseif there are no active read locks, otherwise returnstrue.booleanReturnsfalseif there are no active write locks, otherwise returnstrue.Gets a read lock, if available.Gets an exclusive write lock, if available.voidBlocks until all read locks have been released.voidBlocks 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()Returnsfalseif there are no active write locks, otherwise returnstrue.- Specified by:
isWriterActivein interfaceReadWriteLockManager
-
isReaderActive
public boolean isReaderActive()Returnsfalseif there are no active read locks, otherwise returnstrue.- Specified by:
isReaderActivein interfaceReadWriteLockManager
-
waitForActiveWriter
Blocks until all write locks have been released.- Specified by:
waitForActiveWriterin interfaceReadWriteLockManager- Throws:
InterruptedException- In case the thread requesting the lock wasinterrupted.
-
waitForActiveReaders
Blocks until all read locks have been released.- Specified by:
waitForActiveReadersin 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:
getReadLockin 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:
getWriteLockin 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:
tryReadLockin interfaceReadWriteLockManager
-
tryWriteLock
Gets an exclusive write lock, if available. This method will return null if the write lock is not immediately available.- Specified by:
tryWriteLockin interfaceReadWriteLockManager
-