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 LockgetReadLock()Gets a read lock.LockgetWriteLock()Gets an exclusive write lock.booleanisReaderActive()Returnsfalseif there are no active read locks, otherwise returnstrue.booleanisWriterActive()Returnsfalseif there are no active write locks, otherwise returnstrue.LocktryReadLock()Gets a read lock, if available.LocktryWriteLock()Gets an exclusive write lock, if available.voidwaitForActiveReaders()Blocks until all read locks have been released.voidwaitForActiveWriter()Blocks until all write locks have been released.
-
-
-
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()
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
public void waitForActiveWriter() throws InterruptedExceptionBlocks until all write locks have been released.- Specified by:
waitForActiveWriterin interfaceReadWriteLockManager- Throws:
InterruptedException- In case the thread requesting the lock wasinterrupted.
-
waitForActiveReaders
public void waitForActiveReaders() throws InterruptedExceptionBlocks until all read locks have been released.- Specified by:
waitForActiveReadersin interfaceReadWriteLockManager- Throws:
InterruptedException- In case the thread requesting the lock wasinterrupted.
-
getReadLock
public Lock getReadLock() throws InterruptedException
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
public Lock getWriteLock() throws InterruptedException
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
public Lock 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
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:
tryWriteLockin interfaceReadWriteLockManager
-
-