-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Hi,
I'm a member of a team that is migrating a large legacy codebase from Parmap-based parallelism to Eio's fine-grained concurrency model. Two of the consequences of this refactoring is that we do not enter Eio's event loop until after some initial computation, and because it isn't feasible to move to Eio all in one go, there is a transitory period where our codebase uses both Parmap and Eio.
Certain functionality during this migration necessitates us knowing whether we are running under Eio or not. (I'll abstract away the gnarly particulars for you.). I, however, could not see anything in the public interface to do this check. So: at present, I've written the following predicate, which I think we can all agree is not ideal:
let has_eio_context () =
(* XXX: This is an abuse of Fiber.check, which is really intended to verify
* whether the running fiber has been canceled. Here, we use it to ascertain
* whether the "running fiber" actually exists (e.g. whether we are in the
* synchronous world or the effects world). *)
try
Eio.Fiber.check ();
true
with
| Stdlib.Effect.Unhandled Eio__core__Cancel.Get_context -> false
| e -> raise e (* Do not swallow a cancelation notification, for example *)Would the maintainers consider exposing this information without needing this sort of "spooky action" check? (I would also love to know whether I've missed a corner case in my above function...). Or, could you kindly point me to the existing check if it exists and I just missed it altogether?
Thanks for all your hard work building Eio.
Cheers,
Nathan