Package org.apache.ignite.internal.util
Class GridAtomicInteger
- java.lang.Object
-
- java.lang.Number
-
- java.util.concurrent.atomic.AtomicInteger
-
- org.apache.ignite.internal.util.GridAtomicInteger
-
- All Implemented Interfaces:
Serializable
public class GridAtomicInteger extends AtomicInteger
Extended version ofAtomicInteger.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 Description GridAtomicInteger()Creates a new AtomicInteger with initial value0.GridAtomicInteger(int initVal)Creates a new AtomicInteger with the given initial value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckAndSet(IgnitePredicate<Integer> p, int update)Atomically updates value only if passed in predicate returnstrue.booleangreaterAndSet(int check, int update)Atomically updates value only ifcheckvalue is greater than current value.booleangreaterEqualsAndSet(int check, int update)Atomically updates value only ifcheckvalue is greater than or equal to current value.booleanlessAndSet(int check, int update)Atomically updates value only ifcheckvalue is less than current value.booleanlessEqualsAndSet(int check, int update)Atomically updates value only ifcheckvalue is less than current value.booleansetIfGreater(int update)Sets value only if it is greater than current one.booleansetIfGreaterEquals(int update)Sets value only if it is greater than or equals to current one.booleansetIfLess(int update)Sets value only if it is less than current one.booleansetIfLessEquals(int update)Sets value only if it is less than or equals to current one.booleansetIfNotEquals(int update)Sets value only if it is not equals to current one.-
Methods inherited from class java.util.concurrent.atomic.AtomicInteger
accumulateAndGet, addAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAcquire, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, getOpaque, getPlain, incrementAndGet, intValue, lazySet, longValue, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Method Detail
-
greaterAndSet
public boolean greaterAndSet(int check, int update)Atomically updates value only ifcheckvalue is greater than current value.- Parameters:
check- Value to check against.update- Value to set.- Returns:
Trueif value was set.
-
greaterEqualsAndSet
public boolean greaterEqualsAndSet(int check, int update)Atomically updates value only ifcheckvalue is greater than or equal to current value.- Parameters:
check- Value to check against.update- Value to set.- Returns:
Trueif value was set.
-
lessAndSet
public boolean lessAndSet(int check, int update)Atomically updates value only ifcheckvalue is less than current value.- Parameters:
check- Value to check against.update- Value to set.- Returns:
Trueif value was set.
-
lessEqualsAndSet
public boolean lessEqualsAndSet(int check, int update)Atomically updates value only ifcheckvalue is less than current value.- Parameters:
check- Value to check against.update- Value to set.- Returns:
Trueif value was set.
-
setIfGreater
public boolean setIfGreater(int update)
Sets value only if it is greater than current one.- Parameters:
update- Value to set.- Returns:
Trueif value was set.
-
setIfGreaterEquals
public boolean setIfGreaterEquals(int update)
Sets value only if it is greater than or equals to current one.- Parameters:
update- Value to set.- Returns:
Trueif value was set.
-
setIfLess
public boolean setIfLess(int update)
Sets value only if it is less than current one.- Parameters:
update- Value to set.- Returns:
Trueif value was set.
-
setIfLessEquals
public boolean setIfLessEquals(int update)
Sets value only if it is less than or equals to current one.- Parameters:
update- Value to set.- Returns:
Trueif value was set.
-
setIfNotEquals
public boolean setIfNotEquals(int update)
Sets value only if it is not equals to current one.- Parameters:
update- Value to set.- Returns:
Trueif value was set.
-
checkAndSet
public boolean checkAndSet(IgnitePredicate<Integer> p, int update)
Atomically updates value only if passed in predicate returnstrue.- Parameters:
p- Predicate to check.update- Value to set.- Returns:
Trueif value was set.
-
-