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
33
34
35       type 'a t
36
37
38       An atomic (mutable) reference to a value of type 'a .
39
40
41
42       val make : 'a -> 'a t
43
44       Create an atomic reference.
45
46
47
48       val get : 'a t -> 'a
49
50       Get the current value of the atomic reference.
51
52
53
54       val set : 'a t -> 'a -> unit
55
56       Set a new value for the atomic reference.
57
58
59
60       val exchange : 'a t -> 'a -> 'a
61
62       Set a new value for the atomic reference, and return the current value.
63
64
65
66       val compare_and_set : 'a t -> 'a -> 'a -> bool
67
68
69       compare_and_set r seen v sets the new value of r to v only if its  cur‐
70       rent  value  is  physically equal to seen -- the comparison and the set
71       occur atomically. Returns true if the comparison succeeded (so the  set
72       happened) and false otherwise.
73
74
75
76       val fetch_and_add : int t -> int -> int
77
78
79       fetch_and_add  r  n atomically increments the value of r by n , and re‐
80       turns the current value (before the increment).
81
82
83
84       val incr : int t -> unit
85
86
87       incr r atomically increments the value of r by 1 .
88
89
90
91       val decr : int t -> unit
92
93
94       decr r atomically decrements the value of r by 1 .
95
96
97
98
99
100OCamldoc                          2021-07-22                         Atomic(3)
Impressum