comments in ws_deque

This commit is contained in:
Simon Cruanes 2023-10-25 22:32:42 -04:00
parent 530507d84e
commit 894851f6e8
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -109,14 +109,17 @@ let pop (self : 'a t) : 'a option =
let x = CA.get arr b in let x = CA.get arr b in
perhaps_shrink self ~bottom:b ~top:t; perhaps_shrink self ~bottom:b ~top:t;
Some x Some x
) else if A.compare_and_set self.top t (t + 1) then ( ) else (
(* exactly one slot, so we might be racing against stealers assert (size = 0);
to update [self.top] *) if A.compare_and_set self.top t (t + 1) then (
let x = CA.get arr b in (* exactly one slot, so we might be racing against stealers
A.set self.bottom (t + 1); to update [self.top] *)
Some x let x = CA.get arr b in
) else A.set self.bottom (t + 1);
None Some x
) else
None
)
let steal (self : 'a t) : 'a option = let steal (self : 'a t) : 'a option =
(* read [top], but do not update [top_cached] (* read [top], but do not update [top_cached]