1Atomic(3)                        OCaml library                       Atomic(3)
2
3
4

NAME

6       Atomic - This module provides a purely sequential implementation of the
7       concurrent atomic references provided by the Multicore  OCaml  standard
8       library:
9

Module

11       Module   Atomic
12

Documentation

14       Module Atomic
15        : sig end
16
17
18       This  module provides a purely sequential implementation of the concur‐
19       rent atomic references provided by the  Multicore  OCaml  standard  li‐
20       brary:
21
22       https://github.com/ocaml-multicore/ocaml-multicore/blob/parallel_mi
23       nor_gc/stdlib/atomic.mli
24
25       This sequential implementation is provided in the interest of  compati‐
26       bility:  when  people  will  start writing code to run on Multicore, it
27       would be nice if their use of Atomic was backward-compatible with older
28       versions  of  OCaml  without  having to import additional compatibility
29       layers.
30
31
32       Since 4.12
33
34
35
36
37
38       type 'a t
39
40
41       An atomic (mutable) reference to a value of type 'a .
42
43
44
45       val make : 'a -> 'a t
46
47       Create an atomic reference.
48
49
50
51       val get : 'a t -> 'a
52
53       Get the current value of the atomic reference.
54
55
56
57       val set : 'a t -> 'a -> unit
58
59       Set a new value for the atomic reference.
60
61
62
63       val exchange : 'a t -> 'a -> 'a
64
65       Set a new value for the atomic reference, and return the current value.
66
67
68
69       val compare_and_set : 'a t -> 'a -> 'a -> bool
70
71
72       compare_and_set r seen v sets the new value of r to v only if its  cur‐
73       rent  value  is  physically equal to seen -- the comparison and the set
74       occur atomically. Returns true if the comparison succeeded (so the  set
75       happened) and false otherwise.
76
77
78
79       val fetch_and_add : int t -> int -> int
80
81
82       fetch_and_add  r  n atomically increments the value of r by n , and re‐
83       turns the current value (before the increment).
84
85
86
87       val incr : int t -> unit
88
89
90       incr r atomically increments the value of r by 1 .
91
92
93
94       val decr : int t -> unit
95
96
97       decr r atomically decrements the value of r by 1 .
98
99
100
101
102
103OCamldoc                          2023-01-23                         Atomic(3)
Impressum