.TH "Atomic" 3o 2023-09-20 OCamldoc "OCaml library" .SH NAME Atomic \- This module provides a purely sequential implementation of the concurrent atomic references provided by the Multicore OCaml standard library: .SH Module Module Atomic .SH Documentation .sp Module .BI "Atomic" : .B sig end .sp This module provides a purely sequential implementation of the concurrent atomic references provided by the Multicore OCaml standard library: .sp https://github\&.com/ocaml\-multicore/ocaml\-multicore/blob/parallel_minor_gc/stdlib/atomic\&.mli .sp This sequential implementation is provided in the interest of compatibility: when people will start writing code to run on Multicore, it would be nice if their use of Atomic was backward\-compatible with older versions of OCaml without having to import additional compatibility layers\&. .sp .B "Since" 4.12 .sp .sp .sp .I type .B 'a .I t .sp An atomic (mutable) reference to a value of type .ft B \&'a .ft R \&. .sp .I val make : .B 'a -> 'a t .sp Create an atomic reference\&. .sp .I val get : .B 'a t -> 'a .sp Get the current value of the atomic reference\&. .sp .I val set : .B 'a t -> 'a -> unit .sp Set a new value for the atomic reference\&. .sp .I val exchange : .B 'a t -> 'a -> 'a .sp Set a new value for the atomic reference, and return the current value\&. .sp .I val compare_and_set : .B 'a t -> 'a -> 'a -> bool .sp .ft B compare_and_set r seen v .ft R sets the new value of .ft B r .ft R to .ft B v .ft R only if its current value is physically equal to .ft B seen .ft R \-\- the comparison and the set occur atomically\&. Returns .ft B true .ft R if the comparison succeeded (so the set happened) and .ft B false .ft R otherwise\&. .sp .I val fetch_and_add : .B int t -> int -> int .sp .ft B fetch_and_add r n .ft R atomically increments the value of .ft B r .ft R by .ft B n .ft R , and returns the current value (before the increment)\&. .sp .I val incr : .B int t -> unit .sp .ft B incr r .ft R atomically increments the value of .ft B r .ft R by .ft B 1 .ft R \&. .sp .I val decr : .B int t -> unit .sp .ft B decr r .ft R atomically decrements the value of .ft B r .ft R by .ft B 1 .ft R \&. .sp