package miaou-driver-matrix

  1. Overview
  2. Docs

Module Miaou_driver_matrix.Matrix_render_loopSource

Render loop for the Matrix driver.

Manages frame rendering in a dedicated OCaml 5 Domain for true parallelism. The render domain runs at configurable FPS, computing diffs between front/back buffers and emitting minimal ANSI sequences.

Architecture:

  • Main domain: Input handling, state updates, writes to back buffer
  • Render domain: Reads buffers, computes diff, writes via output sink

The buffer uses mutex synchronization for thread safety.

Sourcetype t

Render loop state.

Sourceval create : config:Matrix_config.t -> buffer:Matrix_buffer.t -> writer:Matrix_ansi_writer.t -> write:(string -> unit) -> t

Create a new render loop (does not start the domain yet).

  • parameter config

    Configuration (FPS cap, debug mode)

  • parameter buffer

    Double buffer for diff computation

  • parameter writer

    ANSI writer for output generation

  • parameter write

    Output sink: sends ANSI string to terminal or WebSocket

Sourceval start : t -> unit

Start the render domain. Call once after setup.

Sourceval request_frame : t -> unit

Request a frame to be rendered (legacy API, now no-op). The render domain automatically renders when buffer is dirty.

Sourceval render_if_needed : t -> bool

Render immediately if buffer is dirty. For use before domain starts or after shutdown. Returns true if a frame was rendered.

Sourceval force_render : t -> unit

Force immediate render regardless of dirty state.

Sourceval shutdown : t -> unit

Shutdown the render loop and join the domain.

Sourceval current_fps : t -> float

Get current achieved FPS - actual renders per second (for diagnostics). Thread-safe.

Sourceval loop_fps : t -> float

Get loop FPS - how fast the render loop is checking (the cap). Thread-safe.

Sourceval frame_pending : t -> bool

Check if buffer needs render.

Sourceval is_running : t -> bool

Check if render domain is running.