RE: [PHP-GTK] while loop and select

From: Date: Mon, 19 Dec 2005 18:49:48 +0000
Subject: RE: [PHP-GTK] while loop and select
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6439@lists.php.net to get a copy of this message
Thanks Andrei. Any idea how efficient that is? I am concerned that all of that polling and looping makes the program terribly really inefficient. My cpu usage usually stays beneath 7%, but it stayed down near 0% (when there were no requests) when I was using blocking selects and NULL for a timeout value. thanks for the help!! will > -------- Original Message -------- > Subject: Re: [PHP-GTK] while loop and select > From: Andrei Zmievski <andrei@gravitonic.com> > Date: Mon, December 19, 2005 12:39 pm > To: Christian Weiske <cweiske@cweiske.de> > Cc: PHP-Gtk-General <php-gtk-general@lists.php.net> > > Do a non-blocking select() with timeout set to 0. If it returns with > descriptors ready, then process them, otherwise call the > while(Gtk::events_pending()) { Gtk::main_iteration(); } loop. > > - Andrei > > On Dec 17, 2005, at 1:14 AM, Christian Weiske wrote: > > > Will, > > > > > >> But when it gets to the select() the program is blocked from execution > >> while it waits for input and so > > That's exactly the problem with not having threads. The main loop can't > > run while the socket reading function blocks program execution > > > >> GTK gets frozen and cannot redraw I suppose. Then it says "Not > >> Responding" and dies. > > You can use the well-known > >> while (Gtk::events_pending()) { Gtk::main_iteration();} > > *if* the code continues and the socket reading function returns after > > some seconds or so. > > That would be possible: > > > > while(socket_not_closed) { > > read_for_some_milliseconds(); > > while (Gtk::events_pending()) { Gtk::main_iteration();} > > } > > > > Just the question where to get the read_for_some_milliseconds() > > function :) > > > > -- > > Regards/MfG, > > Christian Weiske > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.gtk.general (#6439) next »