package eio

  1. Overview
  2. Docs

This library is used to write event traces using OCaml's runtime events infrastructure.

type id = int
type obj_ty =
  1. | Promise
  2. | Semaphore
  3. | Stream
  4. | Mutex
    (*

    Types of recorded objects.

    *)
val obj_ty_to_string : obj_ty -> string
type cc_ty =
  1. | Switch
  2. | Protect
  3. | Sub
  4. | Root
  5. | Any
    (*

    Types of cancellation contexts.

    *)
val cc_ty_to_string : cc_ty -> string

Writing events

val create_fiber : (id * id) Runtime_events.User.t
val create_cc : (id * cc_ty) Runtime_events.User.t
val create_obj : (id * obj_ty) Runtime_events.User.t
val log : string Runtime_events.User.t
val enter_span : string Runtime_events.User.t
val exit_span : unit Runtime_events.User.t
val name : (id * string) Runtime_events.User.t
val suspend_fiber : string Runtime_events.User.t
val exit_cc : unit Runtime_events.User.t
val exit_fiber : id Runtime_events.User.t
val error : (id * exn) Runtime_events.User.t

Consuming events

type event = [
  1. | `Create of id * [ `Fiber_in of id | `Cc of cc_ty | `Obj of obj_ty ]
  2. | `Fiber of id
    (*

    The given fiber is now running.

    *)
  3. | `Name of id * string
    (*

    Names a promise, stream, etc.

    *)
  4. | `Log of string
    (*

    The running fiber logs a message.

    *)
  5. | `Enter_span of string
    (*

    The running fiber enters a traced section.

    *)
  6. | `Exit_span
    (*

    The running fiber leaves the current traced section.

    *)
  7. | `Get of id
    (*

    The running fiber gets a value from a promise, stream, acquires a lock, etc.

    *)
  8. | `Try_get of id
    (*

    The running fiber wants to get, but must wait.

    *)
  9. | `Put of id
    (*

    The running fiber resolves a promise, adds to a stream, releases a lock etc.

    *)
  10. | `Error of id * string
    (*

    A CC fails with the given error.

    *)
  11. | `Exit_cc
    (*

    The current CC ends.

    *)
  12. | `Exit_fiber of id
    (*

    The running fiber ends.

    *)
  13. | `Suspend_domain of Runtime_events.Type.span
    (*

    The domain asks the OS to wait for events.

    *)
  14. | `Suspend_fiber of string
    (*

    The running fiber is suspended (until resumed by `Fiber).

    *)
]
val pp_event : Format.formatter -> event -> unit

pp_event formats an event as a human-readable string

add_callbacks fn x adds event handler fn to x.

When an Eio event is processed, it calls fn ring_id ts event.

OCaml

Innovation. Community. Security.