[zeromq-dev] Threading questions

gonzalo diethelm gdiethelm at dcv.cl
Thu Feb 18 21:00:24 CET 2010

The documentation for zmq_init() says this about the two initial


1. app_threads specifies maximal number of application threads that
can own open sockets at the same time. At least one application thread
should be defined.
2. io_threads specifies the size of thread pool to handle I/O
operations. The value shouldn't be negative. Zero can be used in case
only in-process messaging is going to be used, i.e. there will be no I/O


Can anybody provide more information about what exactly one is
controlling with app_threads? What happens if I specify 2 but use a
socket on only one of them?


Say I want to have threading operations on three separate threads. Do I
have to call zmq_init() just once, with app_threads = 3, before I spawn
the threads? Or do I have to call zmq_init() once on each thread, each
time with app_threads = 3?


Can I have more than one thread calling zmq_recv() on different sockets
at the same time?


I want to have a program that receives a constant stream of business
messages and, every once in a while, a couple of "administrative"
messages (enquiring state, asking it to pause or shut down, etc.). I
think I have at least two ways of doing this:


1. One socket, one thread receiving messages, it decides what kind
of message it is (business or administrative) and processes it.
2. Two sockets, two threads. On one thread I only receive business
messages on the business socket; on the other thread I only receive
administrative messages on the administrative socket.


Is there any advantage you can see on one method over the other? Model 2
seems to provide a better abstraction.


Are all of the threading rules the same when using 0mq on C / C++ and
when using it on Java?




Gonzalo Diethelm 


Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100218/e0ff3527/attachment.htm>

More information about the zeromq-dev mailing list