I'm wondering how do I start the Async scheduler, run a deferred and then stop it again (terminating my program).
My current code is this:
let () =
Thread_safe.block_on_async_exn @@ fun () ->
after (Core.Std.Time.Span.of_sec 1.) >>= fun _ ->
Which would have been perfect, but it is very unreliable. Sometimes it works (when the amount of secs is for example 0, sometimes it fails and does nothing.
What is the proper way for this to be done?