ocaml-multicore / picos

Interoperable effects based concurrency
https://ocaml-multicore.github.io/picos/doc/picos/index.html
ISC License
86 stars 3 forks source link

Change `Picos_lwt` to take `module System` as argument #152

Closed polytypic closed 4 months ago

polytypic commented 4 months ago

The System module is then used to give both a sleep function and a kind of trigger mechanism. The trigger mechanism is needed to be able to safely wake up Lwt in a multi threaded and/or multi domain program. I think it could actually be a good idea to add more multicore OCaml to Lwt to allow some way to safely interact with Lwt from any systhread on any domain.

This PR also tweaks the way the Test_scheduler does things and sets up signal handling in a way that it can work with both Picos_stdio.Unix and Lwt_unix. However, the approach done to setup signal handling is a bit of hack, IMHO. It does seem to work, but this should probably be revisited at some point. Ideally there would be some library that allows other libraries to setup signal handlers more cooperatively. The current unix/stdlib approach to setting up signal handling is non-composable and non-cooperative.