Module Eio_runtime_eventsSource

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

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

    Types of recorded objects.

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

    Types of cancellation contexts.

    *)
Sourceval cc_ty_to_string : cc_ty -> string

Writing events

Sourceval create_fiber : (id * id) Runtime_events.User.t
Sourceval enter_span : string Runtime_events.User.t
Sourceval exit_span : unit Runtime_events.User.t
Sourceval name : (id * string) Runtime_events.User.t
Sourceval suspend_fiber : string Runtime_events.User.t
Sourceval exit_cc : unit Runtime_events.User.t
Sourceval error : (id * exn) Runtime_events.User.t
Sourceval domain_spawn : id Runtime_events.User.t

Consuming events

Sourcetype 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).

    *)
  15. | `Domain_spawn of id
    (*

    The current domain was spawned by fiber id.

    *)
]
Sourceval 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.