[zeromq-dev] non blocking receive and api_thread_poll_rate
Павел Гуща
pavimus at gmail.com
Tue Jul 28 01:41:55 CEST 2009
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() ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090728/26c0d0db/attachment.htm>
More information about the zeromq-dev
mailing list