.TH "Stdlib.Atomic" 3o 2023-09-18 OCamldoc "OCaml library" .SH NAME Stdlib.Atomic \- no description .SH Module Module Stdlib.Atomic .SH Documentation .sp Module .BI "Atomic" : .B (module Stdlib__Atomic) .sp .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