Package org.apache.ignite.internal.util
Class GridKeyLock
- java.lang.Object
-
- org.apache.ignite.internal.util.GridKeyLock
-
public class GridKeyLock extends Object
This is an utility class for 'splitting' locking of some resources.Map resources values to some number of locks, and supply convenience methods to obtain and release these locks using key values.
-
-
Constructor Summary
Constructors Constructor Description GridKeyLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Objectlock(T key)<T> ObjectlockInterruptibly(T key)StringtoString()<T> @Nullable ObjecttryLock(T key)<T> voidunlock(T key, Object sync)
-
-
-
Method Detail
-
lockInterruptibly
public <T> Object lockInterruptibly(T key) throws InterruptedException
- Parameters:
key- Key to lock.- Returns:
- Sync object that should be passed to
unlock(Object, Object)method. - Throws:
InterruptedException- If interrupted while acquiring lock.
-
lock
public <T> Object lock(T key)
- Parameters:
key- Key to lock.- Returns:
- Sync object that should be passed to
unlock(Object, Object)method.
-
tryLock
@Nullable public <T> @Nullable Object tryLock(T key)
- Parameters:
key- Key to lock.- Returns:
- Sync object that should be passed to
unlock(Object, Object)method ornullif try lock failed.
-
unlock
public <T> void unlock(T key, Object sync)- Parameters:
key- Key.sync- Sync that got fromlockInterruptibly(Object)call.
-
-