[zeromq-dev] Edge-triggered polling vs Level-triggered. Which one ZMQ is using? Why?

Goswin von Brederlow goswin-v-b at web.de
Mon Aug 18 12:39:38 CEST 2014


On Fri, Aug 15, 2014 at 01:22:53PM +0300, artemv.zmq wrote:
> hi Goswin
> 
> You mentioned:
> 
> >With a level trigger you can poll() and then consume one message from
> >every socket that has input available. Rince and repeat. No socket can
> >starve any other.
> 
> Why polling every time and do 1-poller-tick/1-msg-handling?  I usually do
> with zmq' poller like following:
> 
> ...
> 
> poller.poll();
> 
> ...
> 
> if (poller.pollin(0)) {
>   for (;;) {
>     frames = socket.recv(DONTWAIT);
>     if (frames == null)
>       break;
> 
>     ... // process frames here.
>   }
> }
> 
> ...
> 
> I.e.  gobble messages until I can consume them.
> 
> 
> BR
> -artemv

Because then one peer might starve every other. Esspecially when
processing a request takes noticable time.

Assume every thing is idle to start with. Now messages start to arrive
on one socket as fast as they can. A bit later other sockets get
messages too. What does your code do?

The poller will return the first socket. You then process messages
from that socket until they are all consumed, which never happens. So
you process and process and process that one socket and never ever
check other sockets.

MfG
	Goswin



More information about the zeromq-dev mailing list