Class StampedLongAdderLockManager
java.lang.Object
org.eclipse.rdf4j.common.concurrent.locks.StampedLongAdderLockManager
A lightweight read/write lock manager that avoids allocating per-lock objects. Readers are tracked using two
LongAdders while writers rely on a StampedLock. The read-lock method returns a constant
stamp (READ_LOCK_STAMP) and writers receive the stamp produced by the underlying StampedLock.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longStamp returned to callers holding a read lock. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanlongreadLock()longlongvoidunlockRead(long stamp) voidunlockWrite(long stamp) voidvoidlong
-
Field Details
-
READ_LOCK_STAMP
public static final long READ_LOCK_STAMPStamp returned to callers holding a read lock. Passing any other value tounlockRead(long)is considered an illegal monitor state.- See Also:
-
-
Constructor Details
-
StampedLongAdderLockManager
public StampedLongAdderLockManager() -
StampedLongAdderLockManager
public StampedLongAdderLockManager(int writePreference, int tryWriteLockMillis)
-
-
Method Details
-
isWriterActive
public boolean isWriterActive() -
isReaderActive
public boolean isReaderActive() -
waitForActiveWriter
- Throws:
InterruptedException
-
waitForActiveReaders
- Throws:
InterruptedException
-
readLock
- Throws:
InterruptedException
-
tryReadLock
public long tryReadLock() -
unlockRead
public void unlockRead(long stamp) -
writeLock
- Throws:
InterruptedException
-
tryWriteLock
public long tryWriteLock() -
unlockWrite
public void unlockWrite(long stamp)
-