On 2013-04-08 16:12, Charles Remes wrote: > On Apr 8, 2013, at 12:40 PM, Matthew Woehlke wrote: >> Is it safe to create and set up, and tear down, my 0MQ socket in the >> ctor/dtor (i.e. in thread A, and poll/recv/etc. in thread B)? Is there >> something I should be doing to make it safe? > > This is answered in the FAQ (http://www.zeromq.org/area:faq). Short answer > is: Yes, go ahead and do this. If it crashes, protect the socket with some > kind of memory barrier (e.g. mutex).
Ah... I think I may have seen that at some point. However I was specifically remembering reading this in the guide: "Don't share ØMQ sockets between threads. ØMQ sockets are not threadsafe. Technically it's possible to migrate a socket from one thread to another but it demands skill. The only place where it's remotely sane to share sockets between threads are in language bindings that need to do magic like garbage collection on sockets." ...which seems to contradict the FAQ. Maybe some less scary text should be used? (As I read the FAQ, it's perfectly safe to migrate a socket just as long as the migration is 'clean', e.g. memory gets synchronized between the last access by thread A and before the first access by thread B.) -- Matthew _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
