Runtime_events.Callbacks(3)
π Runtime_events.Callbacks π
okay so bestie, you're on the Runtime_events.Callbacks page from the OCaml library manual, and the vibe is callback central π
β¨ It's a tiny module, but it's got main character energy fr fr.
β¨ NAME β¨
Runtime_events.Callbacks β no description. Yep, that's literally all it says. No cap. π
π¦ Module π¦
The module line is right here:
Module Runtime_events.Callbacks
Short and sweet, periodt. π«Ά
π Documentation π
πΈ Module Callbacks πΈ
Module Callbacks
: sig end
This is the module signature, and it ends immediately. Iconic minimalism, honestly. π
π type t π
type t β Type of callbacks. That's the whole official note, and it ate. π
π val create π
val create : ?runtime_begin:(int -> Runtime_events.Timestamp.t ->
Runtime_events.runtime_phase -> unit) -> ?runtime_end:(int ->
Runtime_events.Timestamp.t -> Runtime_events.runtime_phase -> unit) ->
?runtime_counter:(int -> Runtime_events.Timestamp.t ->
Runtime_events.runtime_counter -> int -> unit) -> ?alloc:(int ->
Runtime_events.Timestamp.t -> int array -> unit) -> ?lifecycle:(int ->
Runtime_events.Timestamp.t -> Runtime_events.lifecycle -> int option ->
unit) -> ?lost_events:(int -> int -> unit) -> unit -> t
This creates a callback that optionally subscribes to one or more runtime events. Obsessed with the flexibility, ngl. π¦
The optional callback subscriptions are these cuties β all optional, all with their exact callback types:
?runtime_beginβ(int -> Runtime_events.Timestamp.t -> Runtime_events.runtime_phase -> unit)?runtime_endβ(int -> Runtime_events.Timestamp.t -> Runtime_events.runtime_phase -> unit)?runtime_counterβ(int -> Runtime_events.Timestamp.t -> Runtime_events.runtime_counter -> int -> unit)?allocβ(int -> Runtime_events.Timestamp.t -> int array -> unit)?lifecycleβ(int -> Runtime_events.Timestamp.t -> Runtime_events.lifecycle -> int option -> unit)?lost_eventsβ(int -> int -> unit)
The first int supplied to callbacks is the ring buffer index. Each domain owns a single ring buffer for the duration of the domain's existence. After a domain terminates, a newly spawned domain may take ownership of the ring buffer. That's the whole ring-buffer tea ββ¨
A runtime_begin callback is called when the runtime enters a new phase (e.g. a runtime_begin with EV_MINOR is called at the start of a minor GC). A runtime_end callback is called when the runtime leaves a certain phase. The runtime_counter callback is called when a counter is emitted by the runtime. lifecycle callbacks are called when the ring undergoes a change in lifecycle and a consumer may need to respond. alloc callbacks are currently only called on the instrumented runtime. lost_events callbacks are called if the consumer code detects some unconsumed events have been overwritten.
Heads up bestie: that lost_events one is literally the βsome unconsumed events got overwrittenβ callback. So if it fires, the consumer code detected it. π
π§ val add_user_event π§
val add_user_event : 'a Runtime_events.Type.t -> (int ->
Runtime_events.Timestamp.t -> 'a Runtime_events.User.t -> 'a -> unit) ->
t -> t
add_user_event ty callback t extends t to additionally subscribe to user events of type ty. When such an event happens, callback is called with the corresponding event and payload. Slay. π«Άπ₯
xoxo, OCamldoc Β· 2026-06-22 Β· this was the Runtime_events.Callbacks(3) page, mwah ππ
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms