Skip to content

Commit

Permalink
Use mutable to guarantee a new Resize _ is allocated
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Allain <[email protected]>
Co-authored-by: Vincent Laviron <[email protected]>
  • Loading branch information
3 people committed Feb 1, 2025
1 parent 98b10d0 commit 1291de8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/picos_aux.htbl/picos_aux_htbl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ('k, 'v, _) tdt =
}
-> ('k, 'v, [> `Cons ]) tdt
| Resize : {
spine : ('k, 'v, [ `Nil | `Cons ]) tdt;
mutable spine : ('k, 'v, [ `Nil | `Cons ]) tdt;
}
-> ('k, 'v, [> `Resize ]) tdt
(** During resizing and snapshotting target buckets will be initialized
Expand Down Expand Up @@ -265,11 +265,8 @@ let[@inline never] rec finish t r =
(** This must be called with [r.pending == Nothing]. *)
let[@inline never] try_resize t r new_capacity ~clear =
(* We must make sure that on every resize we use a physically different
[Resize _] value to indicate unprocessed target buckets. The use of
[Sys.opaque_identity] below ensures that a new value is allocated. *)
let resize_avoid_aba =
if clear then B Nil else B (Resize { spine = Sys.opaque_identity Nil })
in
[Resize _] value to indicate unprocessed target buckets. *)
let resize_avoid_aba = if clear then B Nil else B (Resize { spine = Nil }) in
let buckets = Atomic_array.make new_capacity resize_avoid_aba in
let non_linearizable_size =
if clear then
Expand Down

0 comments on commit 1291de8

Please sign in to comment.