[zeromq-dev] adding timeout in zmq_poll

Pavel Gushcha pavimus at gmail.com
Tue Dec 29 00:25:52 CET 2009


I did patch, but when i tried to test it, something goes wrong. I
tried my test program on unmodified zmq2 and get same problem.

I attached modified display.cpp (that binds to some address) and
prompt.cpp that connects to it. When i try to start display:
./display tcp://127.0.0.1:5000
i get error:
Assertion failed: false (sub.cpp:155)

What i'm doing wrong?

I found discrepancy in zmq_poll manpage. in zmq_pollitem_t section
ZMQ_POLLIN and ZMQ_POLLOUT is discussed, but in example section only
POLLIN is used.


2009/12/28 Martin Sustrik <sustrik at 250bpm.com>:
> Pavel Gushcha wrote:
>
>>        2) If user specified too small timeout (1 nsec) must we increase
>>        this timeout to one ms in linux and 1microsec in windows?
>>
>>
>>    I would rather decrease the number. The semantics of the timeout is
>>    "zmq_poll will return before the timeout expires" (see the previous
>>    discussion on returning with no events).
>>
>>
>> If specified timeout is greater than OS API timeout granularity we can
>> without problem decrease it. I speak about case, when user specified timeout
>> lesser, than timeout granularity in OS API. Timeout will be calculated as
>> zero and user will get 100% cpu usage in thread that executes zmq_poll() in
>> loop.
>
> I don't think that's a problem. If you specify very low timeout, high CPU
> usage is to be expected. It's a natural behaviour.
>
> On the other hand, not adhering to timing guarantees can cause serious
> problems in real-time applications.
>
> Martin
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: display.cpp
Type: text/x-c
Size: 1686 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091229/e0e36e1f/attachment.bin>


More information about the zeromq-dev mailing list