[zeromq-dev] context

Martin Sustrik sustrik at 250bpm.com
Thu Aug 26 11:28:08 CEST 2010


Hi Ilja,

> In my application I use zeromq for two logically different purposes.
> Sockets of two logical groups are never mixed in a zmq_poll. One
> group use inproc only, other inproc and tcp.
>
> The question is if having two contexts initialized with 0 and 1
> threads is beneficial from performance point of view, or it is better
> to have one context for both.

The context is just a place to store "global" variables. Using real 
global variables in a library is dangerous, thus the context.

So the rule of the thumb is: Use one context per executable or library.

> Could someone please shed some light on zmq_init argument. I just
> want to be sure I am not "doing weird stuff to need more than one I/O
> thread".

The argument is just the size of the thread pool used to handle the I/O 
operations. In 99% of cases you want just a single I/O thread.

Martin




More information about the zeromq-dev mailing list