[zeromq-dev] app_threads in zmq_init() call
sustrik at 250bpm.com
Fri Apr 16 09:57:44 CEST 2010
> I have a question about the app_threads parameter of the zmq_init() call.
> My application creates thread on user request which may use a ZMQ
> socket. I am not able to know in advance what will be the exact number
> of threads running in my application.
> Which value can I give to this app_threads parameter in this case?
> Do I have to inform the ZMQ context that a new thread has been created
> (or distroyed)?
There's no such way. 0MQ needs to know max number of threads in advance
so that it can initialise the lock-free infrastructure (channels between
However, note the app_thread is max number of threads that can open 0MQ
sockets _in parellel_. This means that once thread X closes all the
socket it owns, another thread can take its place.
Thus I would just estimate how many threads are going to use 0MQ in
parallel (10, 100, 1000?) and set the context accordingly.
> BTW, there is a small typo in the 2.0.6 release man pages. In the
> zmq_setsockopt man page, in the example section about I/O thread affinity,
> the comment talk about port number 5556 while in the example code it's
> port number 5555.
Fixed. Thanks for spotting it!
More information about the zeromq-dev