public interface CasBox<T> extends Box<T>
Modifier and Type | Method and Description |
---|---|
boolean |
compareAndSet(T expect,
T update)
The compare and set method which this box is capable of using.
|
T |
getAndSet(T newValue)
Gets the current value, and sets it with a new one.
|
default <R> CasBox<R> |
map(Converter<T,R> converter) |
default T |
modify(Function<? super T,? extends T> mutator)
Applies the given mutator function to this box, which may require
calling the function more than once, so make sure it's pure!
The function is called using the box's current input, and
compareAndSet is used to
ensure that the input does not change. |
static <T> CasBox<T> |
of(T value)
Returns a CasBox around the given value.
|
accept, from, ofVolatile, set
boolean compareAndSet(T expect, T update)
default T modify(Function<? super T,? extends T> mutator)
compareAndSet
is used to
ensure that the input does not change.
The implementation is more or less verbatim from Rich Hickey's
[Clojure](https://github.com/clojure/clojure/blob/bfb82f86631bde45a8e3749ea7df509e59a0791c/src/jvm/clojure/lang/Atom.java#L75-L87).static <T> CasBox<T> of(T value)