package picos_std
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3f5a08199cf65c2dae2f7d68f3877178f1da8eabf5376e15114e5a8958087dfa
sha512=ad24910c47ce614268c4268874bb918da7f8b5f03b3ad706bbf30323635262e94ddab6be24eaebbca706bfa82c0a517d4272b396459e020c185942125c9bdb7b
doc/picos_std.structured/Picos_std_structured/Bundle/index.html
Module Picos_std_structured.BundleSource
An explicit dynamic bundle of fibers guaranteed to be joined at the end.
Bundles allow you to conveniently structure or delimit concurrency into nested scopes. After a bundle returns or raises an exception, no fibers forked to the bundle remain.
An unhandled exception, or error, within any fiber of the bundle causes all of the fibers forked to the bundle to be canceled and the bundle to raise the error exception or error exceptions raised by all of the fibers forked into the bundle.
Represents a bundle of fibers.
join_after scope calls scope with a bundle. A call of join_after returns or raises only after scope has returned or raised and all forked fibers have terminated. If scope raises an exception, error will be called.
The optional on_return argument specifies what to do when the scope returns normally. It defaults to `Wait, which means to just wait for all the fibers to terminate on their own. When explicitly specified as ~on_return:`Terminate, then terminate ?callstack will be called on return. This can be convenient, for example, when dealing with daemon fibers.
terminate bundle cancels all of the forked fibers using the Terminate exception. After terminate has been called, no new fibers can be forked to the bundle.
The optional callstack argument specifies the number of callstack entries to capture with the Terminate exception. The default is 0.
ℹ️ Calling terminate at the end of a bundle can be a convenient way to cancel any background fibers started by the bundle.
ℹ️ Calling terminate does not raise the Terminate exception, but blocking operations after terminate will raise the exception to propagate cancelation unless propagation of cancelation is forbidden.
terminate_after ~seconds bundle arranges to terminate the bundle after the specified timeout in seconds.
fork bundle action is equivalent to fork_as_promise bundle action |> ignore.