Skip to main content

Module writer

Module writer 

Source
Expand description

Dedicated writer task for high-throughput frame sending.

This module replaces the Arc<Mutex<BoxedWriter>> pattern with a dedicated writer task that receives frames via an mpsc channel. This eliminates lock contention and enables batching multiple frames into single syscalls.

§Architecture

Handler 1 ─┐
Handler 2 ─┼─► mpsc::Sender<OutboundFrame> ─► Writer Task ─► Pipe
Handler N ─┘

§Benefits

  • No lock contention: Channel-based, not mutex-based
  • Batching: Multiple frames can be written in a single syscall via writev
  • Backpressure: Built-in pending count tracking with configurable limits

Structs§

OutboundFrame
A frame ready to be written to the pipe.
WriterConfig
Configuration for the writer task.
WriterHandle
Handle for sending frames to the writer task.

Constants§

DEFAULT_BACKPRESSURE_TIMEOUT
Default backpressure timeout.
DEFAULT_CHANNEL_CAPACITY
Default channel capacity.
DEFAULT_MAX_PENDING_FRAMES
Default maximum pending frames before backpressure kicks in.

Functions§

spawn_writer_task
Spawn the writer task and return a handle for sending frames.
spawn_writer_task_default
Spawn the writer task with default configuration.