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/output.ml.html
Source file output.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
type t = { mutable buf: Buf.t; mutable send_buf: Buf.t -> unit; buf_pool: Buf_pool.t; } let create ~(buf_pool : Buf_pool.t) ~send_buf () : t = let buf_size = buf_pool.buf_size in let buf = Buf.create buf_size in { buf; send_buf; buf_pool } open struct (* NOTE: there is a potential race condition if an output is flushed from the main thread upon closing, while the local thread is blissfully writing new records to it as we're winding down the collector. This is trying to reduce the likelyhood of a race happening. *) let[@poll error] replace_buf_ (self : t) (new_buf : Buf.t) : Buf.t = let old_buf = self.buf in self.buf <- new_buf; old_buf let flush_ (self : t) : unit = let new_buf = Buf_pool.alloc self.buf_pool in let old_buf = replace_buf_ self new_buf in self.send_buf old_buf let[@inline never] cycle_buf (self : t) ~available : Buf.t = flush_ self; let buf = self.buf in if Buf.available buf < available then failwith "fuchsia: buffer is too small"; buf end let[@inline] flush (self : t) : unit = if Buf.size self.buf > 0 then flush_ self (** Obtain a buffer with at least [available] bytes *) let[@inline] get_buf (self : t) ~(available_word : int) : Buf.t = let available = available_word lsl 3 in if Buf.available self.buf >= available then self.buf else cycle_buf self ~available let into_buffer ~buf_pool (buffer : Buffer.t) : t = let send_buf (buf : Buf.t) = Buffer.add_subbytes buffer buf.buf 0 buf.offset in create ~buf_pool ~send_buf () let dispose (self : t) : unit = flush_ self; Buf_pool.recycle self.buf_pool self.buf; self.buf <- Buf.empty
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>