|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.concurrent.atomic.AtomicReferenceArray<E>
com.atlassian.util.concurrent.atomic.AtomicReferenceArray<E>
public class AtomicReferenceArray<E>
AtomicReferenceArray with richer functionality. This class implements
commonly implemented patterns of use of compareAndSet such as
#getAndSetIf(int, Object, Object)
and update(int, Function)
.
Constructor Summary | |
---|---|
AtomicReferenceArray(E[] initialValue)
Creates a new AtomicReferenceArray with the same length as, and all elements copied from, the given array. |
|
AtomicReferenceArray(int length)
Creates a new AtomicReferenceArray of given length. |
Method Summary | |
---|---|
E |
getOrSetAndGetIf(int index,
E oldValue,
E newValue)
Check the current value and if it matches the old value argument, set it to the new value and return that instead. |
E |
getOrSetAndGetIf(int index,
E oldValue,
com.google.common.base.Supplier<E> newValue)
Check the current value and if it matches the old value argument, set it to the one created by the new value supplier and return that
instead. |
E |
update(int index,
com.google.common.base.Function<E,E> newValueFactory)
Do the actual update. |
Methods inherited from class java.util.concurrent.atomic.AtomicReferenceArray |
---|
compareAndSet, get, getAndSet, lazySet, length, set, toString, weakCompareAndSet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AtomicReferenceArray(int length)
length
- the length of the arraypublic AtomicReferenceArray(E[] initialValue)
array
- the array to copy elements from
java.lang.NullPointerException
- if array is nullMethod Detail |
---|
public final E getOrSetAndGetIf(int index, E oldValue, com.google.common.base.Supplier<E> newValue)
new value supplier
and return that
instead. If the old value argument does not match, ignore both and just
return the current value.
T
- the object type.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 final E getOrSetAndGetIf(int index, E oldValue, E newValue)
T
- the object type.oldValue
- to check the current value against (reference equality
check only)newValue
- the new value to set it to
public final E update(int index, com.google.common.base.Function<E,E> newValueFactory)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |