Picos.Handler
Handler for the effects based operations of Picos for OCaml 4.
type 'c t = {
current : 'c -> Fiber.t;
spawn : 'a. 'c ->
forbid:bool ->
'a Computation.t ->
(unit -> unit) list ->
unit;
yield : 'c -> unit;
cancel_after : 'a. 'c -> 'a Computation.t -> seconds:float -> Exn_bt.t -> unit;
await : 'c -> Trigger.t -> Exn_bt.t option;
}
A record of implementations of the primitive effects based operations of Picos. The operations take a context of type 'c
as an argument.
val using : 'c t -> 'c -> (unit -> 'a) -> 'a
using handler context thunk
sets the handler
and the context
for the handler of the primitive effects based operations of Picos while running thunk
.
âšī¸ The behavior is that
using
stores the handler
in TLS
, which allows the operations to be accessed during the execution of the thunk
, andusing
runs thunk
with a deep effect handler that delegates to the operations of the handler
.â ī¸ While this works on OCaml 5, you usually want to use a scheduler that implements an effect handler directly, because that is likely to perform better.