package lsp
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=35e8c7341f8eb1fa39fb0f0e0701a7ed90b9a0bb89ccf84b7ed997cd258cbec3
sha512=c96a7a3ca845ec193e9edc4a74804a22d6e37efc852b54575011879bd2105e0df021408632219f542ca3ad85b36b5c8b72f2b417204d154d5f0dd0839535afa5
doc/lsp.fiber/Fiber/index.html
Module Fiber
Source
Concurrency library
This module implements "structured concurrency".
Generals
Type of fiber. A fiber represent a suspended computation. Note that using the same fiber twice will execute it twice, which is probably not what you want. To share the result of a fiber, use an Ivar.t
.
Converts a thunk to a fiber, making sure the thunk runs in the context of the fiber (rather than applied in the current context).
Equivalent to (>>=) (return ())
, but more explicit.
Joining
The following combinators are helpers to combine the result of several fibers into one. Note that they do not introduce parallelism.
Execute a list of fibers in sequence. We use the short name to conform with the Applicative
interface.
Forking + joining
The following functions combine forking 2 or more fibers followed by joining the results. The execution of the various fibers might be interleaved, however once the combining fiber has terminated, it is guaranteed that there are no fibers lingering around.
Start two fibers and wait for their results.
Same but assume the first fiber returns unit
.
Provide efficient parallel iter/map functions for maps.
Local storage
Error handling
val with_error_handler :
(unit -> 'a t) ->
on_error:(Stdune.Exn_with_backtrace.t -> unit t) ->
'a t
with_error_handler f ~on_error
calls on_error
for every exception raised during the execution of f
. This include exceptions raised when calling f ()
or during the execution of fibers after f ()
has returned. Exceptions raised by on_error
are passed on to the parent error handler.
It is guaranteed that after the fiber has returned a value, on_error
will never be called.
val map_reduce_errors :
(module Stdune.Monoid with type t = 'a) ->
on_error:(Stdune.Exn_with_backtrace.t -> 'a t) ->
(unit -> 'b t) ->
('b, 'a) Stdune.result t
val collect_errors :
(unit -> 'a t) ->
('a, Stdune.Exn_with_backtrace.t list) Stdune.Result.t t
collect_errors f
is: fold_errors f ~init:[] ~on_error:(fun e l -> e :: l)
finalize f ~finally
runs finally
after f ()
has terminated, whether it fails or succeeds.
reraise_all exns
re-raises all exns
to the current error handler