|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.util.concurrent.atomic.Atomics
@ThreadSafe public final class Atomics
Utility methods for handling the specifics of correctly using the CAS
operations on AtomicReference
classes and the like.
All methods are thread safe.
Method Summary | ||
---|---|---|
static boolean |
getAndSetIf(java.util.concurrent.atomic.AtomicBoolean reference,
boolean oldValue,
boolean newValue)
Get the current value of the reference but if it
matches the oldValue argument, compare-and-set it to one created by the
newValue Supplier . |
|
static long |
getAndSetIf(java.util.concurrent.atomic.AtomicInteger reference,
int oldValue,
int newValue)
Get the current value of the reference but if it
matches the oldValue argument, compare-and-set it to one created by the
newValue Supplier . |
|
static long |
getAndSetIf(java.util.concurrent.atomic.AtomicLong reference,
long oldValue,
long newValue)
Get the current value of the reference but if it
matches the oldValue argument, compare-and-set it the new value. |
|
static
|
getAndSetIf(java.util.concurrent.atomic.AtomicReference<T> reference,
T oldValue,
Supplier<T> newValue)
Get the current value of the reference but if it
matches the oldValue argument, compare-and-set it to one created by the
new value supplier . |
|
static
|
getAndSetIf(java.util.concurrent.atomic.AtomicReference<T> reference,
T oldValue,
T newValue)
Check the current value of the reference and if
it matches the old value argument, compare-and-set it to the new value
and return that instead. |
|
static
|
getAndSetIf(java.util.concurrent.atomic.AtomicReferenceArray<T> reference,
int index,
T oldValue,
Supplier<T> newValue)
Get the current value of the array reference
but if it matches the oldValue argument, compare-and-set it to one
created by the new value supplier . |
|
static
|
getAndSetIf(java.util.concurrent.atomic.AtomicReferenceArray<T> reference,
int index,
T oldValue,
T newValue)
Get the current value of the array reference
but if it matches the oldValue argument, compare-and-set it the new
value. |
|
static
|
getAndSetIfNull(java.util.concurrent.atomic.AtomicReference<T> reference,
Supplier<T> newValue)
Get the current value of the reference but if it
is null, compare-and-set it to one created by the new value
Supplier . |
|
static
|
getAndSetIfNull(java.util.concurrent.atomic.AtomicReference<T> reference,
T newValue)
Get the current value of the reference but if it
is null, compare-and-set it the new value. |
|
static
|
getAndSetIfNull(java.util.concurrent.atomic.AtomicReferenceArray<T> reference,
int index,
Supplier<T> newValue)
Get the current value of the array reference
but if it is null, compare-and-set it to one created by the new value
Supplier . |
|
static
|
getAndSetIfNull(java.util.concurrent.atomic.AtomicReferenceArray<T> reference,
int index,
T newValue)
Get the current value of the array reference
but if it is null, compare-and-set it the new value |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T getAndSetIf(java.util.concurrent.atomic.AtomicReference<T> reference, T oldValue, Supplier<T> newValue)
reference
but if it
matches the oldValue argument, compare-and-set it to one created by the
new value supplier
.
T
- the object type.reference
- the reference to get the value from.oldValue
- to check the current value against (reference equality
check only).newValue
- a Supplier
for a new value. May be called more
than once.
public static <T> T getAndSetIf(java.util.concurrent.atomic.AtomicReference<T> reference, T oldValue, T newValue)
reference
and if
it matches the old value argument, compare-and-set it to the new value
and return that instead. If the old value argument does not match, ignore
both and return the current value.
T
- the object type.reference
- the reference to get the value fromoldValue
- to check the current value against (reference equality
check only)newValue
- the new value to set it to
public static <T> T getAndSetIfNull(java.util.concurrent.atomic.AtomicReference<T> reference, Supplier<T> newValue)
reference
but if it
is null, compare-and-set it to one created by the new value
Supplier
.
T
- the object type.reference
- the reference to get the value fromnewValue
- a Supplier
for a new value. May be called more
than once.
public static <T> T getAndSetIfNull(java.util.concurrent.atomic.AtomicReference<T> reference, T newValue)
reference
but if it
is null, compare-and-set it the new value.
T
- the object type.reference
- the reference to get the value fromnewValue
- the new value.
public static <T> T getAndSetIf(java.util.concurrent.atomic.AtomicReferenceArray<T> reference, int index, T oldValue, Supplier<T> newValue)
array reference
but if it matches the oldValue argument, compare-and-set it to one
created by the new value supplier
.
T
- the object type.index
- the index to the itemreference
- the reference to get the value fromoldValue
- to check the current value against (reference equality
check only)newValue
- a Supplier
for a new value. May be called more
than once.
java.lang.IndexOutOfBoundsException
- if the index is less than 0 or equal or
greater than the array sizepublic static <T> T getAndSetIf(java.util.concurrent.atomic.AtomicReferenceArray<T> reference, int index, T oldValue, T newValue)
array reference
but if it matches the oldValue argument, compare-and-set it the new
value.
T
- the object type.index
- the index to the itemreference
- the reference to get the value fromoldValue
- to check the current value against (reference equality
check only)newValue
- the new value.
java.lang.IndexOutOfBoundsException
- if the index is less than 0 or equal or
greater than the array sizepublic static <T> T getAndSetIfNull(java.util.concurrent.atomic.AtomicReferenceArray<T> reference, int index, Supplier<T> newValue)
array reference
but if it is null, compare-and-set it to one created by the new value
Supplier
.
T
- the object type.index
- the index to the item.reference
- the reference to get the value from.newValue
- a Supplier
for a new value. May be called more
than once.
java.lang.IndexOutOfBoundsException
- if the index is less than 0 or equal or
greater than the array size.public static <T> T getAndSetIfNull(java.util.concurrent.atomic.AtomicReferenceArray<T> reference, int index, T newValue)
array reference
but if it is null, compare-and-set it the new value
T
- the object type.index
- the index to the item.reference
- the reference to get the value from.newValue
- the new value.
java.lang.IndexOutOfBoundsException
- if the index is less than 0 or equal or
greater than the array size.public static long getAndSetIf(java.util.concurrent.atomic.AtomicLong reference, long oldValue, long newValue)
reference
but if it
matches the oldValue argument, compare-and-set it the new value.
T
- the object type.reference
- the reference to get the value fromoldValue
- to check the current value against.newValue
- the new value.
public static long getAndSetIf(java.util.concurrent.atomic.AtomicInteger reference, int oldValue, int newValue)
reference
but if it
matches the oldValue argument, compare-and-set it to one created by the
newValue Supplier
.
T
- the object type.reference
- the reference to get the value fromoldValue
- to check the current value against.newValue
- the new value.
public static boolean getAndSetIf(java.util.concurrent.atomic.AtomicBoolean reference, boolean oldValue, boolean newValue)
reference
but if it
matches the oldValue argument, compare-and-set it to one created by the
newValue Supplier
.
T
- the object type.reference
- the reference to get the value fromoldValue
- to check the current value against.newValue
- the new value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |