Package org.apache.ignite.internal.util
Class StripedCompositeReadWriteLock
- java.lang.Object
-
- org.apache.ignite.internal.util.StripedCompositeReadWriteLock
-
- All Implemented Interfaces:
ReadWriteLock
public class StripedCompositeReadWriteLock extends Object implements ReadWriteLock
ReadWriteLock with striping mechanics. Compared toReentrantReadWriteLockit has slightly improved performance ofReadWriteLock.readLock()operations at the cost ofReadWriteLock.writeLock()operations and memory consumption. It also supports reentrancy semantics likeReentrantReadWriteLock.
-
-
Constructor Summary
Constructors Constructor Description StripedCompositeReadWriteLock(int concurrencyLvl)Creates a new instance with given concurrency level.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetReadHoldCount()Queries the number of reentrant read holds on this lock by the current thread.booleanisWriteLockedByCurrentThread()Queries if the write lock is held by the current thread.@NotNull LockreadLock()@NotNull LockwriteLock()
-
-
-
Method Detail
-
readLock
@NotNull public @NotNull Lock readLock()
- Specified by:
readLockin interfaceReadWriteLock
-
writeLock
@NotNull public @NotNull Lock writeLock()
- Specified by:
writeLockin interfaceReadWriteLock
-
isWriteLockedByCurrentThread
public boolean isWriteLockedByCurrentThread()
Queries if the write lock is held by the current thread.- Returns:
trueif the current thread holds the write lock andfalseotherwise
-
getReadHoldCount
public int getReadHoldCount()
Queries the number of reentrant read holds on this lock by the current thread. A reader thread has a hold on a lock for each lock action that is not matched by an unlock action.- Returns:
- the number of holds on the read lock by the current thread, or zero if the read lock is not held by the current thread
-
-