@@ -10,21 +10,25 @@ module Trigger = struct
1010
1111 and t = state Atomic. t
1212
13- let finish t ~allow_awaiting =
13+ let finish t ~run_action =
1414 match Atomic. get t with
1515 | Signaled -> ()
1616 | Awaiting r as before ->
17- if allow_awaiting then begin
18- if Atomic. compare_and_set t before Signaled then r.action t r.x r.y
19- end
20- else error_awaiting before
17+ if
18+ Bool. to_int (Atomic. compare_and_set t before Signaled )
19+ land Bool. to_int run_action
20+ != 0
21+ then r.action t r.x r.y
2122 | Initial ->
2223 if not (Atomic. compare_and_set t Initial Signaled ) then begin
2324 match Atomic. get t with
2425 | Signaled | Initial -> ()
2526 | Awaiting r as before ->
26- if allow_awaiting && Atomic. compare_and_set t before Signaled then
27- r.action t r.x r.y
27+ if
28+ Bool. to_int (Atomic. compare_and_set t before Signaled )
29+ land Bool. to_int run_action
30+ != 0
31+ then r.action t r.x r.y
2832 end
2933
3034 let on_signal t x y action =
@@ -52,8 +56,8 @@ module Trigger = struct
5256
5357 let [@ inline] from_action x y action = Atomic. make (Awaiting { action; x; y })
5458 let [@ inline] is_signaled t = Atomic. get t == Signaled
55- let [@ inline] signal t = finish t ~allow_awaiting : true
56- let [@ inline] dispose t = finish t ~allow_awaiting : false
59+ let [@ inline] signal t = finish t ~run_action : true
60+ let [@ inline] dispose t = finish t ~run_action : false
5761
5862 (* END TRIGGER BOOTSTRAP *)
5963
@@ -293,7 +297,7 @@ module Computation = struct
293297 end
294298
295299 let detach t trigger =
296- Trigger. signal trigger;
300+ Trigger. dispose trigger;
297301 unsafe_unsuspend t Backoff. default |> ignore
298302
299303 (* * This cannot be [@@unboxed] because [Atomic.t] is opaque *)
0 commit comments