-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide Lwt.sleep
as a Unix-less function
#924
Comments
Hi, Your approach seems a bit invasive for our use case (MirageOS) where we implement our own scheduler with our own More concretely, we must be sure that |
Thanks for the comment. The timing is what is giving me the most doubts and I'm happy to have a more concrete example to check. I'll have a look at it and see if I can refine the proposal to take it into account. |
What's the actual problem you're trying to fix here, @raphael-proust @hhugo? It would be good to see a small example of something that needs to sleep in a platform-independent way for both jsoo and unix compilation, and then it'll be easier to figure out how Mirage fits into it. In most cases, the amount of time something sleeps for is pretty closely tied to the IO usage, which in turn is tied to the backend in use. |
Whilst discussing js-of-ocaml programs with @hhugo , we discussed the possibility of providing a platform-independent
Lwt.sleep
. The functionLwt.sleep
would be toLwt_unix.sleep
likeLwt.pause
is toLwt_unix.yield
. Below is a short description of a possible implementation. Please provide comments, feedback, ideas, etc.And then when we call
Lwt_main.run
it installs a proper callback before entering the loop:I omitted some details (e.g., exception management around the call to
run_loop
), but the gist is here.A serious issue of the approach shown here is that the timers start ticking down only once the call to
run
is made. I'm not sure how to resolve this without introducing a call to a function to get time which would be backend dependent.Maybe the engine needs to set the sleep-injection function before the scheduler starts. Basically, as soon as the
current_engine
is set.Ideas? Comments?
The text was updated successfully, but these errors were encountered: