[zeromq-dev] Thread Safe sockets
Gary Wright
at2002+zmq at me.com
Fri Feb 3 17:24:22 CET 2012
On Feb 3, 2012, at 11:05 AM, john skaller wrote:
>
>> A mutex works fine with a 0mq socket so adding one to the socket itself would also work. I just don't think it would perform well plus everyone would have to pay that price even if they didn't need it. Yuck.
>
> I have implemented (but not tested) thread safe sockets, available in Pull request.
>
> YMMV. Perhaps it should go in a branch or not get pulled at all.
Can you describe a use case where you want multiple threads to send/recv messages on the same socket?
The non-mutex/0MQ way to solve this problem (I think) is to
a) have each thread establish its own connection(s) into the ZMQ topology (i.e. don't share a connection!)
b) insert a mux/demux thread to coordinate everything:
client1 -----\
+-- mux ---->
client2 -----/
The mux thread is event driven and shuttles messages as needed.
What am I missing?
Gary Wright
More information about the zeromq-dev
mailing list