Ok, I think I did things correctly. I am trying to inform the other threads(except the parent thread) of updates that are sent from zookeeper. So I decided to use a pub/sub to inform them of the changes, + router/dealer for the acknowledgements.
zookeeper only allows you to define functions that are triggered on asynchronous events. 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. >Could you be more specific? I'll expand the zthread manual as needed. 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. I think that in the guide there is only the notion of the "context", something you create at the beginning and then stop worrying about it. >It must monitor its pipe, and exit if the > pipe becomes unreadable. 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) 2012/10/19 Pieter Hintjens <[email protected]> > On Fri, Oct 19, 2012 at 8:16 AM, Apostolis Xekoukoulotakis > <[email protected]> wrote: > > > I would like to know when it is possible to pass a socket without > creating > > problems? > > You're using CZMQ, I assume...? > > You can pass a socket from one thread to another if you do not use it > in the original thread after you create the child thread (that acts as > a full memory barrier). The child thread must close it. > > Are you sure you can't create the socket in the child thread where it > belongs? You can use a separate context and a known TCP endpoint. > > > I create worker threads with zthread_fork (czmq) and I want that the pub > > socket send messages to workers. Will this work? How can it work? > > Workers create SUB sockets and connect them to a tcp:// endpoint that > is a PUB socket; whether it's another thread, process, or box, doesn't > matter. > > If you want to use an inproc transport then you must ensure all > threads get the same context. However you can still create the PUB > socket in the thread that uses it, and then you must create it and > bind it before you start the worker threads. > > > I would also like to point out that zthread manual contains information > that > > is not self complete, the missing parts are not contained in the guide. > It > > requires either knowledge of the internals of zeromq or (on threading in > > general?). > > Could you be more specific? I'll expand the zthread manual as needed. > > -Pieter > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > -- Sincerely yours, Apostolis Xekoukoulotakis
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
