package telemetry

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file telemetry.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
type event = ..
type handler = event -> unit

let handlers : handler list Atomic.t = Atomic.make []

let rec attach_many fn =
  let old_hs = Atomic.get handlers in
  let new_hs = fn :: old_hs in
  if Atomic.compare_and_set handlers old_hs new_hs then () else attach_many fn

let attach handler = attach_many handler

let emit event =
  let handlers = Atomic.get handlers in
  List.iter (fun h -> h event) handlers