package trace-fuchsia

  1. Overview
  2. Docs

Module Trace_fuchsia.Buf_chainSource

A set of buffers in use, and a set of ready buffers

Sourcetype buffers =
  1. | B_one of {
    1. mutable buf : Buf.t;
    }
  2. | B_many of Buf.t Trace_fuchsia__.Lock.t array
    (*

    mask(thread id) -> buffer. This reduces contention

    *)

Buffers in use

Sourcetype t = {
  1. bufs : buffers;
  2. has_ready : bool Atomic.t;
  3. ready : Buf.t Queue.t Trace_fuchsia__.Lock.t;
    (*

    Buffers that are full (enough) and must be written

    *)
  4. buf_pool : Buf_pool.t;
}

A set of buffers, some of which are ready to be written

Sourceval create : sharded:bool -> buf_pool:Buf_pool.t -> unit -> t

Create a buffer chain.

  • parameter sharded

    if true, multiple buffers are created, to reduce contention on each buffer in case of concurrent access. This makes the buf chain thread-safe. If false, there is only one (unprotected) buffer.

Sourceval ready_all_non_empty : t -> unit

Move all non-empty buffers to ready

Sourceval has_ready : t -> bool
Sourceval pop_ready : t -> f:(Buf.t Queue.t -> 'a) -> 'a

Get access to ready buffers, then clean them up automatically

Sourceval max_size_word : t -> int

Maximum size available, in words, for a single message

Sourceval with_buf : t -> available_word:int -> (Buf.t -> 'a) -> 'a

Obtain a buffer with at least available_word 64-bit words

Sourceval dispose : t -> unit

Dispose of resources (here, recycle buffers)