Skip to main content

spawn_reader

Function spawn_reader 

Source
pub fn spawn_reader<A: Application, R: AsRawFd + Send + 'static>(
    producer: Producer<InputSlot<A::Event>>,
    decoder: Arc<dyn RequestDecoder<Event = A::Event>>,
    halt: HaltGate,
    refusals: RefusalSender<A::Report>,
    control_tx: Sender<ControlEvent>,
    core: usize,
    connection_timeout: Option<Duration>,
    tick_cadence: Option<Duration>,
    shutdown: Arc<AtomicBool>,
) -> UringReaderHandle<R>
where A::Event: Send + Sync + 'static, A::Report: Send + 'static,
Expand description

Spawn the io_uring reader thread. Returns a handle for registering connections.

One reader thread serves every TCP connection on the server. io_uring with multishot RECV multiplexes thousands of sockets efficiently and the matching stage is the throughput limit, so adding more reader threads would not raise throughput — it would only re-introduce contention on the input ring’s multi-producer cursor.

tick_cadence: Some(d) makes the reader the engine’s tick generator: it arms an IORING_OP_TIMEOUT so submit_and_wait returns at the tick deadline even when no client traffic is flowing, then publishes a JournalEvent::Tick { now_ns } onto the same input ring it uses for client requests. Pass None to disable the tick (useful for benchmarks that don’t exercise time-driven features).

While halt refuses writes, the reader answers them through refusals instead of publishing them — see crate::halt.