org.apache.ignite.internal.util

## Class GridAtomicLong

- java.lang.Object
- - java.lang.Number
  - - java.util.concurrent.atomic.AtomicLong
    - - org.apache.ignite.internal.util.GridAtomicLong

All Implemented Interfaces:
  Serializable

    public class GridAtomicLong
    extends AtomicLong

Extended version of `AtomicLong`.

In addition to operations provided in java atomic data structures, this class also adds greater than and less than atomic set operations.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridAtomicLong()` Creates a new AtomicLong with initial value `0`.
`GridAtomicLong(long initVal)` Creates a new AtomicLong with the given initial value.

### Method Summary

Methods
`boolean` `checkAndSet(IgnitePredicate<Long> p, long update)` Atomically updates value only if passed in predicate returns `true`.
`boolean` `greaterAndSet(long check, long update)` Atomically updates value only if `check` value is greater than current value.
`boolean` `greaterEqualsAndSet(long check, long update)` Atomically updates value only if `check` value is greater than or equal to current value.
`boolean` `lessAndSet(long check, long update)` Atomically updates value only if `check` value is less than current value.
`boolean` `lessEqualsAndSet(long check, long update)` Atomically updates value only if `check` value is less than current value.
`boolean` `setIfGreater(long update)` Sets value only if it is greater than current one.
`boolean` `setIfGreaterEquals(long update)` Sets value only if it is greater than or equals to current one.
`boolean` `setIfLess(long update)` Sets value only if it is less than current one.
`boolean` `setIfLessEquals(long update)` Sets value only if it is less than or equals to current one.
`boolean` `setIfNotEquals(long update)` Sets value only if it is not equals to current one.

### Methods inherited from class java.util.concurrent.atomic.AtomicLong

`addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, incrementAndGet, intValue, lazySet, longValue, set, toString, weakCompareAndSet`

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

`byteValue, shortValue`

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

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

### Constructor Detail

#### GridAtomicLong

    public GridAtomicLong()

Creates a new AtomicLong with initial value `0`.

#### GridAtomicLong

    public GridAtomicLong(long initVal)

Creates a new AtomicLong with the given initial value.

Parameters:
  `initVal` - the initial value

### Method Detail

#### greaterAndSet

    public boolean greaterAndSet(long check,
                        long update)

Atomically updates value only if `check` value is greater than current value.

Parameters:
  `check` - Value to check against.
  `update` - Value to set.
Returns:
  `True` if value was set.

#### greaterEqualsAndSet

    public boolean greaterEqualsAndSet(long check,
                              long update)

Atomically updates value only if `check` value is greater than or equal to current value.

Parameters:
  `check` - Value to check against.
  `update` - Value to set.
Returns:
  `True` if value was set.

#### lessAndSet

    public boolean lessAndSet(long check,
                     long update)

Atomically updates value only if `check` value is less than current value.

Parameters:
  `check` - Value to check against.
  `update` - Value to set.
Returns:
  `True` if value was set.

#### lessEqualsAndSet

    public boolean lessEqualsAndSet(long check,
                           long update)

Atomically updates value only if `check` value is less than current value.

Parameters:
  `check` - Value to check against.
  `update` - Value to set.
Returns:
  `True` if value was set.

#### setIfGreater

    public boolean setIfGreater(long update)

Sets value only if it is greater than current one.

Parameters:
  `update` - Value to set.
Returns:
  `True` if value was set.

#### setIfGreaterEquals

    public boolean setIfGreaterEquals(long update)

Sets value only if it is greater than or equals to current one.

Parameters:
  `update` - Value to set.
Returns:
  `True` if value was set.

#### setIfLess

    public boolean setIfLess(long update)

Sets value only if it is less than current one.

Parameters:
  `update` - Value to set.
Returns:
  `True` if value was set.

#### setIfLessEquals

    public boolean setIfLessEquals(long update)

Sets value only if it is less than or equals to current one.

Parameters:
  `update` - Value to set.
Returns:
  `True` if value was set.

#### setIfNotEquals

    public boolean setIfNotEquals(long update)

Sets value only if it is not equals to current one.

Parameters:
  `update` - Value to set.
Returns:
  `True` if value was set.

#### checkAndSet

    public boolean checkAndSet(IgnitePredicate<Long> p,
                      long update)

Atomically updates value only if passed in predicate returns `true`.

Parameters:
  `p` - Predicate to check.
  `update` - Value to set.
Returns:
  `True` if value was set.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017