Package org.apache.ignite.internal.util
Class GridStripedLock
java.lang.Object
org.apache.ignite.internal.util.GridStripedLock
This is an utility class for 'splitting' locking of some
int- or long-keyed resources.
Map int and long values to some number of locks,
and supply convenience methods to obtain and release these locks using key values.-
Constructor Summary
ConstructorsConstructorDescriptionGridStripedLock(int concurrencyLevel) Creates new instance with the given concurrency level (number of locks). -
Method Summary
Modifier and TypeMethodDescriptionintGets concurrency level.getLock(int key) ReturnsLockobject for the given key.getLock(long key) ReturnsLockobject for the given key.Returns lock for object.voidlock(int key) Locks given key.voidlock(long key) Locks given key.voidLocks an object.toString()voidunlock(int key) Unlocks given key.voidunlock(long key) Unlocks given key.voidUnlocks an object.
-
Constructor Details
-
GridStripedLock
public GridStripedLock(int concurrencyLevel) Creates new instance with the given concurrency level (number of locks).- Parameters:
concurrencyLevel- Concurrency level.
-
-
Method Details
-
concurrencyLevel
public int concurrencyLevel()Gets concurrency level.- Returns:
- Concurrency level.
-
getLock
ReturnsLockobject for the given key.- Parameters:
key- Key.- Returns:
- Lock.
-
getLock
ReturnsLockobject for the given key.- Parameters:
key- Key.- Returns:
- Lock.
-
getLock
Returns lock for object.- Parameters:
o- Object.- Returns:
- Lock.
-
lock
public void lock(int key) Locks given key.- Parameters:
key- Key.
-
unlock
public void unlock(int key) Unlocks given key.- Parameters:
key- Key.
-
lock
public void lock(long key) Locks given key.- Parameters:
key- Key.
-
unlock
public void unlock(long key) Unlocks given key.- Parameters:
key- Key.
-
lock
Locks an object.- Parameters:
o- Object.
-
unlock
Unlocks an object.- Parameters:
o- Object.
-
toString
-