Module Miou.Hook

type t

Type of hooks.

val add : (unit -> unit) -> t

add fn adds a new hook (a function) which will be executed at every tick of the current domain. This means that each time an effect is suspended, the function will be executed. Here's an example:

# Miou.run @@ fun () ->
  let _hook = Miou.Hook.add @@ fun () -> print_endline "Hello" in
  Miou.yield ();
  Miou.yield () ;;
Hello
Hello
- : unit = ()

A hook is local to the current domain and runs on the domain in which it was created. A hook cannot interact with the scheduler and, what's more, cannot use the effects associated with Miou. Miou's effects manager is not attached to it. If the given function raises an argument, the hook is deleted. The user can remove the actual hook with remove.

val remove : t -> unit

remove h removes the hook h. If h does not belong to the current domain, it raises an exception Invalid_argument.