Skip to main content

spawn_reader_pump

Function spawn_reader_pump 

Source
pub fn spawn_reader_pump(
    worker: Worker,
    sock: Arc<TcpStream>,
    label: &str,
    chunk_size: usize,
    queue_depth: usize,
) -> (ChannelReader, ReaderPumpGuard)
Expand description

Drive sock’s read half on a pooled worker, yielding the AsyncRead half of the seam and the guard that retires the job.

Infallible: the thread already exists — it is the leased worker — so there is no creation to fail. Admission failure now lives in WorkerPool::acquire, which is where it belongs.

queue_depth is the chunk channel’s depth. One is the faithful choice for a demand-driven frame reader — one read per poll, each frame dispatched fully before the next read — because it reproduces that with at most one chunk of read-ahead, which the kernel receive buffer already provides. A larger depth lets a fast peer queue chunks while a slow consumer blocks: a behaviour change, not an optimisation.