package trace-fuchsia
A high-performance backend for trace, emitting a Fuchsia trace into a file
Install
Dune Dependency
Authors
Maintainers
Sources
trace-0.6.tbz
sha256=97cc4159b96429adc01a84bff1ed34b8f06746bc56a40a214a6306036be2df38
sha512=6a67ea9ddeebb4b93a0b8dba9ed26d95e786722d08fd9ca7d8e2db7651a9b9d6ccc63cc437b4eb71c28b3ec51838716a84707a8d366abb595f32a5e65035e28b
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)"
>