FreeYourSoul
FreeYourSoul

Reputation: 364

ZMQ asynchronous, how does it work exactly?

I am currently working on a project that recquire fast network management. To do so I choosed 0MQ, but after reading the documentation and example given by this one. There is something I hardly understand concerning the asynchronous part of 0MQ.

Is there any thread created for each request on a ROUTER or DEALER socket ?

I often do the mistake to combine asynchronous and multi-threaded. When I look at the man of zmqsocket I see that for a DEALER or ROUTER socket, the incoming routing is setted at "Fair-queued". From this I conclude asynchronous means you can write or read on the socket without waiting for an answer to send another request (everything is queued and process synchronously).

So here is the question,

Is there any thread created by 0MQ concerning each request ? (I am not talking about the background thread 0MQ use internally to manage message queueing).

Upvotes: 3

Views: 1125

Answers (1)

somdoron
somdoron

Reputation: 4832

Zeromq creates only one thread. No additional thread is created for request or a socket.

The background thread does all the work and the user thread communicate with the background threads using queues and file descriptors.

The background thread is using epoll or kqueue to do the asynchronous magic.

You can actually control the amount of background threads, but usually it is one.

Upvotes: 5

Related Questions