Module AtomicMarkableReference

module AtomicMarkableReference: sig .. end
Atomic containers for markable values.

type 'a t 
The type of atomic containers for markable 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).

type mark = bool 
The type of marks.
val make : 'a -> mark -> 'a t
Returns a new container holding the passed value, with the passed mark.
val attempt_mark : 'a t -> 'a -> mark -> bool
attempt_mark a e m sets the mark to m if the current value is e. Returns whether the value of a was equal to e.
val compare_and_set : 'a t ->
'a ->
'a -> mark -> mark -> bool
compare_and_set a er ur em um atomically sets the value of a to ur and mark to um if the current value is er and the current mark is em. Returns whether the value of a was equal to er and the mark was equal to em.
val get : 'a t -> 'a * mark
Returns the current value and mark.
val get_reference : 'a t -> 'a
Returns the current value.
val is_marked : 'a t -> bool
Returns the current mark.
val set : 'a t -> 'a -> mark -> unit
set a x m sets the value of a to x, and the mark to m.
val weak_compare_and_set : 'a t ->
'a ->
'a -> mark -> mark -> bool
Similar to compare_and_set, with a weak semantics: may be faster on some platforms, but does not provide ordering guarantees.