Is there a way to share
SplitSink
between two different threads?
Yes
The best way to do this is to create an mpsc
channel that forwards messages to the SplitSink
. In the example below you can see that multiple threads can send to the sink using sender.clone()
. Both send_task
and recv_task
are doing this, and in theory you can make as many senders as you like.
use std::net::SocketAddr;
use std::sync::Arc;