package moonpool
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3efd095c82a37bba8c7ab6a2532aee3c445ebe1ecaed84ef3ffb560bc65e7633
sha512=e4bcab82e6638299c2d0beb1dbf204f7b43379a5387418c6edff85b9bf90c13ad1bdd8eb44b69cd421268d1bc45bcf918bcf77e1c924348211ac27d6643aac78
doc/moonpool/Moonpool/Runner/index.html
Module Moonpool.Runner
Source
Interface for runners.
This provides an abstraction for running tasks in the background, which is implemented by various thread pools.
A runner.
If a runner is no longer needed, shutdown
can be used to signal all worker threads in it to stop (after they finish their work), and wait for them to stop.
The threads are distributed across a fixed domain pool (whose size is determined by Domain.recommended_domain_count
on OCaml 5, and simple the single runtime on OCaml 4).
Current number of tasks. This is at best a snapshot, useful for metrics and debugging.
Shutdown the pool, and do not wait for it to terminate. Idempotent.
run_async pool f
schedules f
for later execution on the runner in one of the threads. f()
will run on one of the runner's worker threads/domains.
run_wait_block pool f
schedules f
for later execution on the pool, 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.
NOTE be careful with deadlocks (see notes in Fut.wait_block
about the required discipline to avoid deadlocks).
Runner that fails when scheduling tasks on it. Calling run_async
on it will raise Failure.
Implementing runners
This module is specifically intended for users who implement their own runners. Regular users of Moonpool should not need to look at it.
Access the current runner. This returns Some r
if the call happens on a thread that belongs in a runner.
get_current_storage runner
gets the local storage for the currently running task.