On Fri, Oct 26, 2012 at 2:03 AM, Kah-Chan Low <[email protected]> wrote:

> 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?

Yes. When you create a new thread you automatically do a "full fence"
memory barrier.

This is how CZMQ creates a parent-to-child thread pipe, for example.
You can see that code in czmq/src/zthread.c

It's meant to be scary because we had so many people just sharing
sockets between threads and then wondering why 0MQ crashes so easily.

-Pieter
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to