Class StampedLockManager
java.lang.Object
org.eclipse.rdf4j.common.concurrent.locks.StampedLockManager
- All Implemented Interfaces:
ReadWriteLockManager
A read/write-lock manager backed by a StampedLock.
This class is in an experimental state: its existence, signature or behavior may change without warning from one release to the next.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LockMonitoring
<StampedLockManager.ReadLock> (package private) final StampedLock
private final int
private final LockMonitoring
<StampedLockManager.WriteLock> -
Constructor Summary
ConstructorsConstructorDescriptionStampedLockManager
(boolean trackLocks) StampedLockManager
(boolean trackLocks, int waitToCollect) StampedLockManager
(String alias, int waitToCollect, LockDiagnostics... lockDiagnostics) StampedLockManager
(String alias, LockDiagnostics... lockDiagnostics) -
Method Summary
Modifier and TypeMethodDescriptionconvertToReadLock
(Lock writeLock) Convert a write lock to a read lock.private StampedLockManager.ReadLock
private StampedLockManager.WriteLock
Gets an optimistic read lock, if available.Gets 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
.private void
spinWait()
Gets a read lock, if available.private StampedLockManager.ReadLock
Gets an exclusive write lock, if available.private StampedLockManager.WriteLock
void
Blocks until all read locks have been released.void
Blocks until all write locks have been released.private long
-
Field Details
-
readLockMonitoring
-
writeLockMonitoring
-
stampedLock
-
tryWriteLockMillis
private final int tryWriteLockMillis
-
-
Constructor Details
-
StampedLockManager
public StampedLockManager() -
StampedLockManager
public StampedLockManager(boolean trackLocks) -
StampedLockManager
public StampedLockManager(boolean trackLocks, int waitToCollect) -
StampedLockManager
-
StampedLockManager
-
-
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
.
-
createReadLockInner
- Throws:
InterruptedException
-
getOptimisticReadLock
Gets an optimistic read lock, if available. This method will return null if the optimistic read lock is not immediately available. -
convertToReadLock
Convert a write lock to a read lock. -
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
.
-
createWriteLockInner
- Throws:
InterruptedException
-
writeLockInterruptibly
- Throws:
InterruptedException
-
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
-
tryReadLockInner
-
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
-
tryWriteLockInner
-
spinWait
- Throws:
InterruptedException
-