Class LoomAtomicReference<T>
java.lang.Object
com.loomcache.client.LoomAtomicReference<T>
- Type Parameters:
T- the reference value type
Client-side distributed atomic reference proxy backed by the CP subsystem.
Operations are linearizable when used against a cluster: mutations are committed through Raft and reads are served through the server's linearizable-read path.
- Since:
- 1.4
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the reference by setting it to null.booleancompareAndSet(@Nullable T expectedValue, @Nullable T newValue) Atomically updates the reference when the current value equals the expected value.@Nullable Tget()Gets the current reference value.booleanisNull()Returns whether the reference currently holds null.voidSets the current reference value.
-
Method Details
-
get
Gets the current reference value.- Returns:
- the current value, or null when the reference is clear
-
set
Sets the current reference value.- Parameters:
value- the new value, or null to clear
-
compareAndSet
Atomically updates the reference when the current value equals the expected value.- Parameters:
expectedValue- the expected current valuenewValue- the new value to store on success- Returns:
- true when the value was updated
-
clear
public void clear()Clears the reference by setting it to null. -
isNull
public boolean isNull()Returns whether the reference currently holds null.
-