Class WritePrefReadWriteLockManager
java.lang.Object
org.eclipse.rdf4j.common.concurrent.locks.AbstractReadWriteLockManager
org.eclipse.rdf4j.common.concurrent.locks.WritePrefReadWriteLockManager
- All Implemented Interfaces:
ReadWriteLockManager
A read/write lock manager with writer preference. As soon as a write lock is requested, this lock manager will block
any read lock requests until the writer's request has been satisfied.
- Author:
- Arjohn Kampman, James Leigh
-
Constructor Summary
ConstructorDescriptionCreates a MultiReadSingleWriteLockManager.WritePrefReadWriteLockManager(boolean trackLocks)
Creates a new MultiReadSingleWriteLockManager, optionally with lock tracking enabled. -
Method Summary
Modifier and TypeMethodDescriptionGets a read lock.Gets an exclusive write lock.Gets a read lock, if available.Gets an exclusive write lock, if available.Methods inherited from class org.eclipse.rdf4j.common.concurrent.locks.AbstractReadWriteLockManager
createReadLock, createWriteLock, isReaderActive, isWriterActive, waitForActiveReaders, waitForActiveWriter
-
Constructor Details
-
WritePrefReadWriteLockManager
public WritePrefReadWriteLockManager()Creates a MultiReadSingleWriteLockManager. -
WritePrefReadWriteLockManager
public WritePrefReadWriteLockManager(boolean trackLocks)Creates a new MultiReadSingleWriteLockManager, optionally with lock tracking enabled.- Parameters:
trackLocks
- Controls whether the lock manager will keep track of active locks. Enabling lock tracking will add some overhead, but can be very useful for debugging.
-
-
Method Details
-
tryReadLock
Gets a read lock, if available. This method will return null if the read lock is not immediately available. -
getReadLock
Gets a read lock. This method blocks when a write lock is in use or has been requested until the write lock is released.- Throws:
InterruptedException
- In case the thread requesting the lock wasinterrupted
.
-
tryWriteLock
Gets an exclusive write lock, if available. This method will return null if the write lock is not immediately available. -
getWriteLock
Gets an exclusive write lock. This method blocks when the write lock is in use or has already been requested until the write lock is released. This method also block when read locks are active until all of them are released.- Throws:
InterruptedException
- In case the thread requesting the lock wasinterrupted
.
-