Package org.apache.ignite.internal.util

## Class InitializationProtector

- java.lang.Object
- - org.apache.ignite.internal.util.InitializationProtector

    public class InitializationProtector
    extends Object

Class for avoid multiple initialization of specific value from various threads.

### Constructor Summary

Constructors
`InitializationProtector()`

### Method Summary

All Methods Instance Methods Concrete Methods
`<T> T` `protect​(Object protectedKey, Supplier<T> initializedVal, IgniteThrowableRunner initializationCode)`
`void` `protect​(Object protectedKey, IgniteThrowableRunner initializationCode)` It method allows to avoid simultaneous initialization from various threads.

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

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

### Constructor Detail

#### InitializationProtector

    public InitializationProtector()

### Method Detail

#### protect

    public <T> T protect​(Object protectedKey,
                         Supplier<T> initializedVal,
                         IgniteThrowableRunner initializationCode)
                  throws IgniteCheckedException

Type Parameters:
  `T` - Type of initialization value.
Parameters:
  `protectedKey` - Unique value by which initialization code should be run only one time.
  `initializedVal` - Supplier for given already initialized value if it exist or null as sign that initialization required.
  `initializationCode` - Code for initialization value corresponding protectedKey. Should be idempotent.
Returns:
  Initialized value.
Throws:
  `IgniteCheckedException` - if initialization was failed.

#### protect

    public void protect​(Object protectedKey,
                        IgniteThrowableRunner initializationCode)
                 throws IgniteCheckedException

It method allows to avoid simultaneous initialization from various threads.

Parameters:
  `protectedKey` - Unique value by which initialization code should be run only from one thread in one time.
  `initializationCode` - Code for initialization value corresponding protectedKey. Should be idempotent.
Throws:
  `IgniteCheckedException` - if initialization was failed.