package trace-fuchsia
A high-performance backend for trace, emitting a Fuchsia trace into a file
Install
Dune Dependency
Authors
Maintainers
Sources
trace-0.8.tbz
sha256=34cfa5662b611c1e246f0fb8131ee605eeb90b359c105e882f51adc7e70878c3
sha512=ea47974a77a0ab26c58fe6d1bc898d4f3e6a5f865e4c1acb4188b9acd7ba8e7527d0ea7f2ae66574ceccc14f11127ee203aedba2be334d17b36c83dabff61261
doc/src/trace-fuchsia.write/buf_pool.ml.html
Source file buf_pool.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
open struct module A = Trace_core.Internal_.Atomic_ exception Got_buf of Buf.t end module List_with_len = struct type +'a t = | Nil | Cons of int * 'a * 'a t let empty : _ t = Nil let[@inline] len = function | Nil -> 0 | Cons (i, _, _) -> i let[@inline] cons x self = Cons (len self + 1, x, self) end type t = { max_len: int; buf_size: int; bufs: Buf.t List_with_len.t A.t; } let create ?(max_len = 64) ?(buf_size = 1 lsl 16) () : t = let buf_size = min (1 lsl 22) (max buf_size (1 lsl 15)) in { max_len; buf_size; bufs = A.make List_with_len.empty } let alloc (self : t) : Buf.t = try while match A.get self.bufs with | Nil -> false | Cons (_, buf, tl) as old -> if A.compare_and_set self.bufs old tl then raise (Got_buf buf) else false do () done; Buf.create self.buf_size with Got_buf b -> b let recycle (self : t) (buf : Buf.t) : unit = Buf.clear buf; try while match A.get self.bufs with | Cons (i, _, _) when i >= self.max_len -> raise Exit | old -> not (A.compare_and_set self.bufs old (List_with_len.cons buf old)) do () done with Exit -> () (* do not recycle *)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>