package moonpool
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0f3d42753c2636a6a55427af89d2574b08a29c32100f2002ae3e47f6e4d23ff1
sha512=7fa651570493ddd7c594eb46b76782610da6a6823e5178c2b20ceafe2f159649caedaac01e975428605de865d3dff9008a798090cec77c909477a86c04532709
doc/moonpool/Moonpool/index.html
Module MoonpoolSource
Moonpool
A pool within a bigger pool (ie the ocean). Here, we're talking about pools of Thread.t that are dispatched over several Domain.t to enable parallelism.
We provide several implementations of pools with distinct scheduling strategies, alongside some concurrency primitives such as guarding locks (Lock.t) and futures (Fut.t).
A simple runner with a single background thread.
Runner that runs tasks in the caller thread.
Exception raised when trying to run tasks on runners that have been shut down.
Similar to Thread.create, but it picks a background domain at random to run the thread. This ensures that we don't always pick the same domain to run all the various threads needed in an application (timers, event loops, etc.)
run_async runner task schedules the task to run on the given runner. This means task() will be executed at some point in the future, possibly in another thread.
run_wait_block runner f schedules f for later execution on the runner, like run_async. It then blocks the current thread until f() is done executing, and returns its result. If f() raises an exception, then run_wait_block pool f will raise it as well.
See run_async for more details.
NOTE be careful with deadlocks (see notes in Fut.wait_block about the required discipline to avoid deadlocks).
Number of threads recommended to saturate the CPU. For IO pools this makes little sense (you might want more threads than this because many of them will be blocked most of the time).
spawn ~on f runs f() on the runner (a thread pool typically) and returns a future result for it. See Fut.spawn.
Await a future, must be run on a moonpool runner. See Await. Only on OCaml >= 5.0.
Yield from the current task, must be run on a moonpool runner. Only on OCaml >= 5.0.
Task-local storage.
A simple blocking queue.
include module type of struct include Main end
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.