pub fn split(stream: ServerStream) -> (ServerReadHalf, ServerWriteHalf)Expand description
Splits an accepted connection into halves that can be owned by two tasks.
The daemon reads requests on one task and writes replies (and pushed bus
events) on another, so the two halves must be separately owned and
'static.
tokio::io::split rather than UnixStream::into_split, which exists
only on unix. The generic split coordinates the two halves through an
internal lock where into_split needs none, so this trades a small,
uncontended synchronisation cost on every frame for one code path on both
platforms. That is the right trade here and would not be everywhere: this
is a control plane carrying operator RPC — a handful of frames per
command — not a data path. Do not copy the reasoning to one.