poll with timeout 0 in main loop




Hi, i have a problem with an application i m building with glib-2.24.2 on linux, i create a server socket 
which i use to create a GIOChannel and add it to a main loop, everything was fine until i found that the 
application consumes 99.8% of the CPU while waiting for connections (doing nothing else just sitting there 
waiting for connections) and it gets even worse as new connections come in because i create a new loop in 
each connection (i create a thread for each connection) to deal with the incoming packages and each 
connection has N handlers to process the requests, each handler has its main loop for asynchronous 
communication between them and the connection thread that owns the handlers, so i did a strace and found out 
that the time out being passed to poll is 0 so for each iteration the poll returns inmediatly therefore i m 
stuck with a busy wait in all main loops, so i have read the documentation trying to find out how to modify 
this bahaviour but i could find nothing about it, can you please tell me why this is happenning ?? thanks!
                                          


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]