From b47da2396e60964f6440991efb59639bc5c11f61 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 26 Jun 2024 11:02:14 -0400 Subject: [PATCH] feat fib: add `Private.cancel_from_outside` --- src/fib/fiber.ml | 4 ++++ src/fib/fiber.mli | 1 + 2 files changed, 5 insertions(+) diff --git a/src/fib/fiber.ml b/src/fib/fiber.ml index c50325b1..b298c243 100644 --- a/src/fib/fiber.ml +++ b/src/fib/fiber.ml @@ -40,6 +40,10 @@ module Private_ = struct match A.get self.state with | Alive _ -> false | Terminating_or_done _ -> true + + let cancel_from_outside (self : _ t) ebt : unit = + Fut.fulfill_idempotent (Fut.Private_.unsafe_promise_of_fut self.res) + @@ Error ebt end include Private_ diff --git a/src/fib/fiber.mli b/src/fib/fiber.mli index d02c4e56..817f3967 100644 --- a/src/fib/fiber.mli +++ b/src/fib/fiber.mli @@ -31,6 +31,7 @@ module Private_ : sig type any = Any : _ t -> any [@@unboxed] val get_cur : unit -> any option + val cancel_from_outside : _ t -> Exn_bt.t -> unit end (**/**)