Class SegmentedReentrantReadWriteLock
java.lang.Object
com.gigaspaces.internal.utils.concurrent.SegmentedReentrantReadWriteLock
A segmented implementation of ReentrantReadWriteLock, providing better concurrency.
- Since:
- 8.0
- Author:
- Niv Ingberg
-
Constructor Summary
ConstructorsConstructorDescriptionSegmentedReentrantReadWriteLock(int numOfSegments, boolean fair) Creates a segmented reentrant read write lock using the specified arguments. -
Method Summary
Modifier and TypeMethodDescriptionvoidacquireReadLock(int segmentId) Acquires a read lock on the specified segment.voidAcquires a read lock on the current thread's segment.voidAcquires the write lock.intGenerates a segment ID from the current thread ID.voidreleaseReadLock(int segmentId) Releases a read lock on the specified segment.voidReleases a read lock on the current thread's segment.voidReleases the write lock.
-
Constructor Details
-
SegmentedReentrantReadWriteLock
public SegmentedReentrantReadWriteLock(int numOfSegments, boolean fair) Creates a segmented reentrant read write lock using the specified arguments.- Parameters:
numOfSegments- Number of segments to allocate.fair- true if this lock should use a fair ordering policy.
-
-
Method Details
-
acquireWriteLock
public void acquireWriteLock()Acquires the write lock. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. -
releaseWriteLock
public void releaseWriteLock()Releases the write lock. -
acquireReadLock
public void acquireReadLock(int segmentId) Acquires a read lock on the specified segment. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. -
releaseReadLock
public void releaseReadLock(int segmentId) Releases a read lock on the specified segment. -
getSegmentIdByCurrentThreadId
public int getSegmentIdByCurrentThreadId()Generates a segment ID from the current thread ID.- Returns:
- a valid segment id.
-
acquireThreadReadLock
public void acquireThreadReadLock()Acquires a read lock on the current thread's segment. -
releaseThreadReadLock
public void releaseThreadReadLock()Releases a read lock on the current thread's segment.
-