Re: while loop and select
| From: | Andrei Zmievski | Date: | Mon, 19 Dec 2005 18:39:52 +0000 |
| Subject: | Re: while loop and select | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6436@lists.php.net to get a copy of this message | ||
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 soThat's exactly the problem with not having threads. The main loop can't run while the socket reading function blocks program executionGTK gets frozen and cannot redraw I suppose. Then it says "Not Responding" and dies.You can use the well-knownwhile (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