[zeromq-dev] Stopping zmq_device
Jarred Ward
jarred at webriots.com
Fri Jul 2 22:42:44 CEST 2010
>
> > The zmq_device method, or rather the associated forwarder, queue, etc
> object constructors, will never return at the moment; you're forced to kill
> the process that is running it in order to stop. I think it would be nice to
> be able to stop them somehow. Right now, I don't use zmq_device for that
> reason; I use my own forwarder code that I can "break" when I need to.
>
> I suggest contributing your code as a patch. If it's agreeable to Martin,
> et al. then everyone will benefit after the patch merge.
>
I would, but my forwarder code is not actually a change to the zmq
code-base. It's a completely separate forwarder that lives within an
application I'm writing.
There are a couple ways I see to stop a device:
- if the device is active a flag could be set from another thread to break
the device loop
- if the the device is blocking at the moment it has to be stopped from
another thread via a device specific term that doesn't tear down the context
Right now I use a combination of the two in my forwarder, but I'm forced to
deal with a complete tear down of the context with my method. Here's the
pseudocode:
The forwarder is essentially this:
while (running) forward_messages
And kill by doing this:
running = false;
zmq_term (ctx);
Again the drawback of this solution is that I have to rebuild the context to
stop the device.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100702/cffb9324/attachment.htm>
More information about the zeromq-dev
mailing list