[zeromq-dev] Migrating ZMQ sockets acrossing threads

Chuck Remes lists at chuckremes.com
Thu Oct 25 19:43:27 CEST 2012

All of the documentation consistently warns you about doing a full-memory barrier (mutex, semaphore, etc) if you are going to use a socket in more than one thread. If you create it in one and pass it to another for operations, then you don't need to be too concerned about this.

So, to answer your question, NO, you don't need a full-memory barrier for your simple example.


On Oct 25, 2012, at 12:03 PM, Kah-Chan Low wrote:

> Hi,
> If I create a ZMQ socket, do not touch it direct or indirectly after this, and spawn a thread and hand over the pointer of socket to the new thread.
> The new thread is the only thread that perform operations on the socket, including deleting the socket.
> Is this the right way to migrate the socket across 2 threads?
> zmq_socket reference manual talks about using "full fence" memory barrier to do this.
> Do I really need to do this for my simple example?
> Thanks!
> kc
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121025/9999a351/attachment.htm>

More information about the zeromq-dev mailing list