[zeromq-dev] non blocking receive and api_thread_poll_rate

Martin Hurton hurtonm at gmail.com
Tue Jul 28 10:32:20 CEST 2009


Hi Pavel,

I have prepared a small patch (see attached file). Could you please apply
it to the trunk and let us know if it solves the delay issue?

- Martin

On Tue, Jul 28, 2009 at 1:41 AM, Павел Гуща<pavimus at gmail.com> wrote:
> I have multithreaded application, powered by 0MQ. One of threads has
> following algorithm:
>
> while (true) {
>    sleep one second;
>    int queue_id=api_thread->receive(my_message,false); // use non blocking
> receive()
>    if (queue_id!=0) break; // break loop, if message was received.
> }
>
> All works, but... time between sending message from another thread and
> breaking loop in this thread is above minute! I looked at zeromq sources and
> see following code in receive function:
>
>     if (++ ticks == api_thread_poll_rate) {
>         ypollset_t::integer_t signals = pollset.check ();
>         if (signals)
>             process_commands (signals);
>         ticks = 0;
>     }
>
> additionally i found, that api_thread_poll_rate is equal to 100. So, time
> between calls of process_commands() for my case (because of sleep) is about
> 100 seconds.
>
> After that, i tried to call "api_thread->flush()" before
> "api_thread->receive()" and this big delay between message sending and
> receiving disappears! This is because flush() function explicitly call
> process_command().
>
> How i can solve this problem in more elegant way than calling flush() ?
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: receive.patch
Type: text/x-diff
Size: 4533 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090728/320381a4/attachment.patch>


More information about the zeromq-dev mailing list