package picos_std
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
doc/picos_std.structured/Picos_std_structured/Bundle/index.html
Module Picos_std_structured.Bundle
Source
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
.