6
6
7
7
Atomically load the value `x` stored in `ref` with ordering `order`. The default ordering
8
8
`Atomix.sequentially_consistent` is used when not specified.
9
+
10
+ # Examples
11
+ ```jldoctest
12
+ julia> using Atomix
13
+
14
+ julia> a = [111, 222, 333];
15
+
16
+ julia> ref = Atomix.IndexableRef(a, (1,));
17
+
18
+ julia> Atomix.get(ref)
19
+ 111
20
+ ```
9
21
"""
10
22
Atomix. get
11
23
@@ -15,6 +27,20 @@ Atomix.get
15
27
16
28
Atomically store the value `x` in `ref` with ordering `order`. The default ordering
17
29
`Atomix.sequentially_consistent` is used when not specified.
30
+
31
+ # Examples
32
+ ```jldoctest
33
+ julia> using Atomix
34
+
35
+ julia> a = [111, 222, 333];
36
+
37
+ julia> ref = Atomix.IndexableRef(a, (1,));
38
+
39
+ julia> Atomix.set!(ref, 123);
40
+
41
+ julia> a[1]
42
+ 123
43
+ ```
18
44
"""
19
45
Atomix. set!
20
46
@@ -24,18 +50,45 @@ Atomix.set!
24
50
25
51
Atomically update `ref` from stored value `old` to `new = op(old, x)` with ordering `order`
26
52
(default: `Atomix.sequentially_consistent`). Return a pair `old => new`.
53
+
54
+ # Examples
55
+ ```jldoctest
56
+ julia> using Atomix
57
+
58
+ julia> a = [111, 222, 333];
59
+
60
+ julia> ref = Atomix.IndexableRef(a, (1,));
61
+
62
+ julia> Atomix.modify!(ref, +, 123)
63
+ 111 => 234
64
+ ```
27
65
"""
28
66
Atomix. modify!
29
67
30
68
"""
31
69
Atomix.swap!(ref, new, order) -> old
32
70
Atomix.swap!(ref, new) -> old
33
71
34
- Swap the `new` value with the ` old` stored in `ref` with ordering `order` (default:
35
- `Atomix.sequentially_consistent`).
72
+ Swap the `old` stored in `ref` with the `new` value and establish the memory ordering
73
+ `order` (default: ` Atomix.sequentially_consistent`).
36
74
37
75
Notes for implementers: `Atomix.swap!(ref, new, order)` is defined as `Atomix.modify!(ref,
38
76
Atomix.right, x, order)`. Thus, only `Atomix.modify!` has to be defined.
77
+
78
+ # Examples
79
+ ```jldoctest
80
+ julia> using Atomix
81
+
82
+ julia> a = [111, 222, 333];
83
+
84
+ julia> ref = Atomix.IndexableRef(a, (1,));
85
+
86
+ julia> Atomix.swap!(ref, 123)
87
+ 111
88
+
89
+ julia> a[1]
90
+ 123
91
+ ```
39
92
"""
40
93
Atomix. swap!
41
94
@@ -46,6 +99,18 @@ Atomix.swap!
46
99
47
100
Atomically replace the value stored in `ref` to `desired` if `expected` is stored. A named
48
101
tuple `(; old::eltype(ref), success::Bool)` is returned.
102
+
103
+ # Examples
104
+ ```jldoctest
105
+ julia> using Atomix
106
+
107
+ julia> a = [111, 222, 333];
108
+
109
+ julia> ref = Atomix.IndexableRef(a, (1,));
110
+
111
+ julia> Atomix.replace!(ref, 111, 123)
112
+ (old = 111, success = true)
113
+ ```
49
114
"""
50
115
Atomix. replace!
51
116
0 commit comments