Module AtomicReference

module AtomicReference: sig .. end
Atomic containers for values.

type 'a t 
The type of atomic containers for values.

WARNING: physical comparison is used by the container.

CONSEQUENCE 1: should be used with caution to store int32, int64, nativeint, or double values as they are wrapped into blocks. Hence, comparisons are done on block addresses rather than on wrapped values.

CONSEQUENCE 2: as OCaml-Java uses boxed values for int values, the container should not be used to store int values.

Any other type can be safely stored (caching of some int values ensure that sum types are correctly handled).

val make : 'a -> 'a t
Returns a new container holding the passed value.
val compare_and_set : 'a t -> 'a -> 'a -> bool
compare_and_set a e u atomically sets the value of a to u if the current value is e. Returns whether the value of a was equal to e.
val get : 'a t -> 'a
Returns the current value.
val get_and_set : 'a t -> 'a -> 'a
get_and_set a x atomically sets the value of a to x, and returns the previous value.
val lazy_set : 'a t -> 'a -> unit
lazy_set a x eventually sets the value of a to x.
val set : 'a t -> 'a -> unit
set a x sets the value of a to x.
val weak_compare_and_set : 'a t -> 'a -> 'a -> bool
Similar to compare_and_set, with a weak semantics: may be faster on some platforms, but does not provide ordering guarantees.