[zeromq-dev] socket passing and thread safety.. a precise exlanation

Pieter Hintjens ph at imatix.com
Sat Oct 20 03:56:31 CEST 2012


On Fri, Oct 19, 2012 at 10:08 PM, Apostolis Xekoukoulotakis
<xekoukou at gmail.com> wrote:
> So I'd have to create a new context inside such a
> triggered event. I think I could do it. Passing the sockets,for now, might
> be enough.

I'd suggest creating a new context in each thread.

> I think I get confused because it introduces 3 concepts, the agent, the zctx
> object and the pipe that is used to communicate between them.

Yes, on re-reading that page it's very unclear. I've rewritten it. See
https://github.com/hintjens/czmq/commit/6788c3222974731de664cc447c2b0d7d0411d6c8

> Also what does this mean? Monitoring the pipe means that I expect that a msg
> will arrive. When It doesnt arrive, I will have to exit.
> Does this also mean that I have to generate that msg? (heartbeat)

It's actually just standard practice on reading _any_ 0MQ socket, if
you get back a null message it means the process has been interrupted
and you have to exit whatever loop you're in.

-Pieter



More information about the zeromq-dev mailing list