From a143cc8489338e8c57e8da5247b52ed81bf414e1 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 3 Oct 2024 13:17:07 -0400 Subject: [PATCH] feat fib: `spawn_ignore` now has `?on` optional param close #33 --- src/fib/fiber.ml | 4 +++- src/fib/fiber.mli | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fib/fiber.ml b/src/fib/fiber.ml index 4af7c798..15589581 100644 --- a/src/fib/fiber.ml +++ b/src/fib/fiber.ml @@ -301,7 +301,9 @@ let spawn ?on ?(protect = true) f : _ t = add_child_ ~protect p child; child -let[@inline] spawn_ignore ?protect f : unit = ignore (spawn ?protect f : _ t) +let[@inline] spawn_ignore ?on ?protect f : unit = + ignore (spawn ?on ?protect f : _ t) + let[@inline] spawn_top_ignore ~on f : unit = ignore (spawn_top ~on f : _ t) let[@inline] self () : any = diff --git a/src/fib/fiber.mli b/src/fib/fiber.mli index 6a2320d7..12d710ad 100644 --- a/src/fib/fiber.mli +++ b/src/fib/fiber.mli @@ -143,10 +143,11 @@ val spawn : ?on:Runner.t -> ?protect:bool -> (unit -> 'a) -> 'a t Must be run from inside a fiber. @raise Failure if not run from inside a fiber. *) -val spawn_ignore : ?protect:bool -> (unit -> _) -> unit +val spawn_ignore : ?on:Runner.t -> ?protect:bool -> (unit -> _) -> unit (** [spawn_ignore f] is [ignore (spawn f)]. The fiber will still affect termination of the parent, ie. the - parent will exit only after this new fiber exits. *) + parent will exit only after this new fiber exits. + @param on the optional runner to use, added since NEXT_RELEASE *) val spawn_top_ignore : on:Runner.t -> (unit -> _) -> unit (** Like {!spawn_top} but ignores the result.