@@ -44,6 +44,7 @@ module Snapshot = struct
44
44
45
45
let [@ inline] set s i after =
46
46
let snap = Array. unsafe_get s i in
47
+ let after = after land max_value in
47
48
let before = Atomic. get snap in
48
49
if
49
50
before = collecting
@@ -53,6 +54,7 @@ module Snapshot = struct
53
54
54
55
let [@ inline] forward s i after =
55
56
let snap = Array. unsafe_get s i in
57
+ let after = after land max_value in
56
58
while
57
59
let before = Atomic. get snap in
58
60
(before = collecting
@@ -170,21 +172,18 @@ let new_once t update =
170
172
let rec update_once txs once counter =
171
173
let before = Atomic. get counter in
172
174
let index = get_index once in
173
- let before_once = before.once in
174
- if index != used_index && before_once != once then begin
175
- use_index before_once;
176
- let value = (before.value + 1 ) land max_value in
177
- let after = { value; once } in
175
+ if index != used_index && before.once != once then begin
176
+ use_index before.once;
177
+ let after = { value = before.value + 1 ; once } in
178
178
if Atomic. compare_and_set counter before after then begin
179
179
let snapshot = Atomic. get (snapshot_of txs) in
180
180
if Snapshot. is_collecting snapshot then
181
- Snapshot. forward snapshot index value
181
+ Snapshot. forward snapshot index after. value
182
182
end
183
183
else update_once txs once (Array. unsafe_get txs index)
184
184
end
185
185
186
- let update_once t once =
187
- match once with
186
+ let update_once t = function
188
187
| Once Used -> ()
189
188
| Once (Open _ as once ) ->
190
189
let index = get_index once in
0 commit comments