Skip to main content

Module comms

Module comms 

Source
Expand description

Inter-thread communication primitives.

Each session::Session owns a dedicated background thread that processes Commands serially. The HTTP / WebSocket / MCP-side handlers run on the tokio runtime and need to ship a Command into that thread plus get a stream of Responses back.

CentralCommand is the thin abstraction that wires that up: a single [tokio::sync::mpsc::unbounded_channel] from handlers to the background loop, plus a per-request reply channel attached to each command. This keeps every request’s responses isolated from every other request’s, while still serialising work inside a session.

Structs§

CentralCommand
This struct contains the senders and receivers necessary to communicate between both threads.

Constants§

THREADS_COMMUNICATION_ERROR
Panic message used when a receiver yields None (the background thread dropped the sender, which means it crashed or exited unexpectedly).
THREADS_SENDER_ERROR
Panic message used when a send into the inter-thread channel fails (the receiver was dropped before we could deliver the message).

Type Aliases§

ThreadReceiver 🔒
Custom type for the thread receiver, so clippy doesn’t complain about long types.