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 and Description
`GridKeyLock()`

### Method Summary

Methods
`<T> Object` `lock(T key)`
`<T> Object` `lockInterruptibly(T key)`
`String` `toString()`
`<T> Object` `tryLock(T key)`
`<T> void` `unlock(T key, Object sync)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridKeyLock

    public GridKeyLock()

### 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> Object tryLock(T key)

Parameters:
  `key` - Key to lock.
Returns:
  Sync object that should be passed to `unlock(Object, Object)` method or `null` if try lock failed.

#### unlock

    public <T> void unlock(T key,
                  Object sync)

Parameters:
  `key` - Key.
  `sync` - Sync that got from `lockInterruptibly(Object)` call.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.9.0
Release Date | : March 2 2017