AtomicUpdater
Value members
Concrete methods
Recursive, atomic updates. If there is an unguaranteed update of atomicity, it may loop indefinitely.
Recursive, atomic updates. If there is an unguaranteed update of atomicity, it may loop indefinitely.
- Value Params
- f
Update function.
Update only if the existing data is in the expected state. If it is not in the expected state, it will not be updated.
Update only if the existing data is in the expected state. If it is not in the expected state, it will not be updated.
- Value Params
- n
Update symbol.
- o
Expected symbol.
Returns a new reference that is the result of the snapshot.
Returns a new reference that is the result of the snapshot.
Atomically sets the field of the given object managed by this updater to the given value and returns the old value.
Atomically sets the field of the given object managed by this updater to the given value and returns the old value.
- Value Params
- n
the new value
- Returns
the previous value
Atomically updates the field of the given object managed by this updater with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
Atomically updates the field of the given object managed by this updater with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
- Value Params
- nf
a side-effect-free function
- Returns
the previous value
- Since
1.8
Gets the current value held in the field of the given object managed by this updater.
Gets the current value held in the field of the given object managed by this updater.
- Returns
the current value
Sets the field of the given object managed by this updater to the given updated value. This operation is guaranteed to act as a volatile store with respect to subsequent invocations of compareAndSet.
Sets the field of the given object managed by this updater to the given updated value. This operation is guaranteed to act as a volatile store with respect to subsequent invocations of compareAndSet.
- Value Params
- n
the new value
Provides a way to create a snapshot if necessary. Usually not processed.
Provides a way to create a snapshot if necessary. Usually not processed.
In that case, response is a reference, so if you change it, it may affect the value that other threads reference. To prevent this, use snapshot or compareAndSet to override snapshot and update.
override def snapshot(w: W): W = w.snapshot()
val old = getRef
val newRef = get
newRef.update(x -> y)
compareAndSet(old, newRef)
- Value Params
- w
value type