Package org.apache.ignite.internal.util
Class GridStripedLock
- java.lang.Object
-
- org.apache.ignite.internal.util.GridStripedLock
-
public class GridStripedLock extends Object
This is an utility class for 'splitting' locking of someint- orlong-keyed resources. Mapintandlongvalues to some number of locks, and supply convenience methods to obtain and release these locks using key values.
-
-
Constructor Summary
Constructors Constructor Description GridStripedLock(int concurrencyLevel)Creates new instance with the given concurrency level (number of locks).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intconcurrencyLevel()Gets concurrency level.LockgetLock(int key)ReturnsLockobject for the given key.LockgetLock(long key)ReturnsLockobject for the given key.LockgetLock(@Nullable Object o)Returns lock for object.voidlock(int key)Locks given key.voidlock(long key)Locks given key.voidlock(@Nullable Object o)Locks an object.StringtoString()voidunlock(int key)Unlocks given key.voidunlock(long key)Unlocks given key.voidunlock(@Nullable Object o)Unlocks an object.
-
-
-
Method Detail
-
concurrencyLevel
public int concurrencyLevel()
Gets concurrency level.- Returns:
- Concurrency level.
-
getLock
public Lock getLock(int key)
ReturnsLockobject for the given key.- Parameters:
key- Key.- Returns:
- Lock.
-
getLock
public Lock getLock(long key)
ReturnsLockobject for the given key.- Parameters:
key- Key.- Returns:
- Lock.
-
getLock
public Lock getLock(@Nullable @Nullable Object o)
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
public void lock(@Nullable @Nullable Object o)Locks an object.- Parameters:
o- Object.
-
unlock
public void unlock(@Nullable @Nullable Object o)Unlocks an object.- Parameters:
o- Object.
-
-