Re: question on glib main loop



On Thu, 28 Feb 2002 17:20:47 +0100
Markus Lausser <sgop users sourceforge net> wrote:

I am trying to figure out why glib does not use 100% CPU
in its main loop, i took a look at the sources, but i couldnt
find the reason. Doesnt it do an endless loop checking
all the sources again and again?
I tried to write my own program that also checks such things
like timeouts, socket read/write-ability (without using glib)
but it uses 100% CPU.
Can anyone explain why glib/gdk/gtk doesnt do that?

without looking at glib, i think it uses blocking io to do so. it will
probably call something like poll() or select() that will only return if
there is something to read or write to/from one of its filedescriptors.

note that you can also use select() in non blocking mode so it will
return imidiatly, even if there is no action to perform on any
filedescriptor.

best regards ...
clemens



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