Skip to main content

await_worker_signal

Function await_worker_signal 

Source
async fn await_worker_signal(
    id: usize,
    handle: &mut JoinHandle<Result<()>>,
    ready_rx: &mut Receiver<Result<usize>>,
) -> Result<usize>
Expand description

Awaits worker id’s readiness signal, but also resolves immediately if the worker’s JoinHandle finishes before signaling readiness.

This is the defensive half of the leader-failure fix: EmbedPool::spawn itself owns the original ready_tx, which it cannot drop until after every follower has been spawned. If the worker panics — or for any future reason drops its ready_tx clone before sending — ready_rx.recv() would never see None (the init task’s own clone is still alive) and the init future would park forever. Selecting on the JoinHandle guarantees we always make progress when the worker exits, regardless of whether the worker had a chance to send its outcome.

Returns the worker’s rss_delta on success. Both branches are propagated as a typed Result<usize> so callers can short-circuit with ? and avoid duplicating error-construction logic at every spawn site.