This thread will be very sensitive to network activity, but it can be guaranteed to process the message queue only 100 times per second. I can continue to reduce latency, but after a certain moment I will be busy waiting and chewing on the processor. Is it true that this solution is as good as I get without switching to another method?
while (1) {
process_thread_message_queue();
struct timeval t;
t.tv_sec = 0;
t.tv_usec = 10 * 1000;
if (select(n,&fdset,0,0,t))
{
...
}
}
source
share