package moonpool
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c4a1f974200530ab7f6014de3a369fdbb260ff454183640f32e51ba3fec51b15
sha512=865daabb96e3d60f88ecee9fc9030dad8b257fff4121b404e882d8a8d6687b737beb6e22366f52eb14e770dfab28b326853a1d3d883fa19bbd791d8450b40f8b
doc/moonpool.fib/Moonpool_fib/index.html
Module Moonpool_fib
Source
Fibers for moonpool.
See Fiber
for the most important explanations.
include module type of struct include Fiber end
A callback used in case of cancellation
A fiber returning a value of type 'a
.
Future result of the fiber.
Callbacks that are called when a fiber is done.
Peek inside the future result
wait_block_exn fib
is Fut.wait_block_exn (res fib)
. NOTE: See Fut.wait_block
for warnings about deadlocks.
wait_block fib
is Fut.wait_block (res fib)
. NOTE: See Fut.wait_block
for warnings about deadlocks.
Check if the current fiber is cancelled, in which case this raises. Must be run from inside a fiber.
Yield control to the scheduler from the current fiber.
An opaque handle for a single cancel callback in a fiber
add_on_cancel fib cb
adds cb
to the list of cancel callbacks for fib
. If fib
is already cancelled, cb
is called immediately.
remove_on_cancel fib h
removes the cancel callback associated with handle h
.
with_on_cancel fib cb (fun () -> <e>)
evaluates e
in a scope in which, if the fiber fib
is cancelled, cb()
is called. If e
returns without the fiber being cancelled, this callback is removed.
with_on_self_cancel cb f
calls f()
in a scope where cb
is added to the cancel callbacks of the current fiber; and f()
terminates, cb
is removed from the list.
Wait for fiber to be done and call the callback with the result. If the fiber is done already then the callback is invoked immediately with its result.
spawn_top ~on f
spawns a new (toplevel) fiber onto the given runner. This fiber is not the child of any other fiber: its lifetime is only determined by the lifetime of f()
.
spawn ~protect f
spawns a sub-fiber f_child
from a running fiber parent
. The sub-fiber f_child
is attached to the current fiber and fails if the current fiber parent
fails.
Must be run from inside a fiber.
spawn_ignore f
is ignore (spawn f)
. The fiber will still affect termination of the parent, ie. the parent will exit only after this new fiber exits.
Like spawn_top
but ignores the result.
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.