Queueing logic in message_sender
The message_sender class defined in network.h#L52 and implemented in message_rx.cc is used to queue messages up to be written to the network.
Currently the message_sender is per-connection and has a queue of per-connection messages tx_queue_
src.
The current implementation has the following properties:
- Not thread-safe -- clients can call
send_message
from any thread - Messages are dropped when connections drop
In the context of the Controller<>Worker API, if the controller disconnects from a worker then reconnects, we'd still like old results to be sent on the new connection.
To do this I suggest the following:
- Pass in the
tx_queue_
in the class constructor - Protect the queue with a mutex or atomic flag
- Only pop the message off the queue once it has completed sending, so that if sending fails part way through, it is still the head of the queue and will be re-sent on the new connection
Child of #2 (closed)
Edited by Jonathan Mace