package moonpool
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c4a1f974200530ab7f6014de3a369fdbb260ff454183640f32e51ba3fec51b15
sha512=865daabb96e3d60f88ecee9fc9030dad8b257fff4121b404e882d8a8d6687b737beb6e22366f52eb14e770dfab28b326853a1d3d883fa19bbd791d8450b40f8b
doc/moonpool.fib/Moonpool_fib/Main/index.html
Module Moonpool_fib.Main
Source
Main thread.
This is evolved from Moonpool.Immediate_runner
, but unlike it, this API assumes you run it in a thread (possibly the main thread) which will block until the initial computation is done.
This means it's reasonable to use Main.main (fun () -> do_everything)
at the beginning of the program. Other Moonpool pools can be created for background tasks, etc. to do the heavy lifting, and the main thread (inside this immediate runner) can coordinate tasks via Fiber.await
.
Aside from the fact that this blocks the caller thread, it is fairly similar to Background_thread
in that there's a single worker to process tasks/fibers.
This handles effects, including the ones in Fiber
.
main f
runs f()
in a scope that handles effects, including Fiber.await
.
This scope can run background tasks as well, in a cooperative fashion.