Picos.Handler
Handler for the effects based operations of Picos for OCaml 4.
type 'c t = {
current : 'c -> Fiber.t;
spawn : 'c -> Fiber.t -> (Fiber.t -> unit) -> unit;
yield : 'c -> unit;
cancel_after : 'a. 'c ->
'a Computation.t ->
seconds:float ->
exn ->
Stdlib.Printexc.raw_backtrace ->
unit;
await : 'c -> Trigger.t -> (exn * Stdlib.Printexc.raw_backtrace) option;
}
A record of implementations of the primitive effects based operations of Picos. The operations take a context of type 'c
as an argument.
using handler context main
sets the handler
and the context
for the handler of the primitive effects based operations of Picos while running main
.
ℹ️ 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.