mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
fix fiber: use a single fut/computation in fibers
otherwise we check the wrong computation for cancellation, see https://discuss.ocaml.org/t/confused-about-moonpool-cancellation/15381
This commit is contained in:
parent
0d8767f45f
commit
6a44598a31
1 changed files with 4 additions and 5 deletions
|
|
@ -57,9 +57,8 @@ end
|
||||||
|
|
||||||
include Private_
|
include Private_
|
||||||
|
|
||||||
let create_ ~pfiber ~runner () : 'a t =
|
let create_ ~pfiber ~runner ~res () : 'a t =
|
||||||
let id = Handle.generate_fresh () in
|
let id = Handle.generate_fresh () in
|
||||||
let res, _ = Fut.make () in
|
|
||||||
{
|
{
|
||||||
state =
|
state =
|
||||||
A.make
|
A.make
|
||||||
|
|
@ -254,8 +253,8 @@ let add_child_ ~protect (self : _ t) (child : _ t) =
|
||||||
done
|
done
|
||||||
|
|
||||||
let spawn_ ~parent ~runner (f : unit -> 'a) : 'a t =
|
let spawn_ ~parent ~runner (f : unit -> 'a) : 'a t =
|
||||||
let comp = Picos.Computation.create () in
|
let res, _ = Fut.make () in
|
||||||
let pfiber = PF.create ~forbid:false comp in
|
let pfiber = PF.create ~forbid:false (Fut.Private_.as_computation res) in
|
||||||
|
|
||||||
(* copy local hmap from parent, if present *)
|
(* copy local hmap from parent, if present *)
|
||||||
Option.iter
|
Option.iter
|
||||||
|
|
@ -265,7 +264,7 @@ let spawn_ ~parent ~runner (f : unit -> 'a) : 'a t =
|
||||||
(match parent with
|
(match parent with
|
||||||
| Some p when is_closed p -> failwith "spawn: nursery is closed"
|
| Some p when is_closed p -> failwith "spawn: nursery is closed"
|
||||||
| _ -> ());
|
| _ -> ());
|
||||||
let fib = create_ ~pfiber ~runner () in
|
let fib = create_ ~pfiber ~runner ~res () in
|
||||||
|
|
||||||
let run () =
|
let run () =
|
||||||
(* make sure the fiber is accessible from inside itself *)
|
(* make sure the fiber is accessible from inside itself *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue