Re: Event loop, non-blocking i/o
- From: DANIELLLANO <DANIELLLANO terra es>
- To: gtk-perl-list gnome org
- Subject: Re: Event loop, non-blocking i/o
- Date: Sat, 11 Dec 2004 20:04:42 GMT
Martin Junius wrote:
In my Gtk2 application gslish, see source at
http://cvs.sourceforge.net/viewcvs.py/slish/slish/perl/glade/gslish?rev=1.14&view=auto
I'm running a computation and i/o extensive loop, which basically
- computes PPM video frames
- and outputs them to a "|ppmtoy4m|mpeg2enc" pipe.
To make the user interface somewhat responsive I've implemented the
following:
- At several points in the frame rendering functions I've added calls to
while (Gtk2->events_pending) {
Gtk2->main_iteration;
}
- Furthermore I set the pipe file handle with fcntl to O_NONBLOCK and am
using syswrite for output to the pipe (this has the disadvantage of
syswrite returning after 4096 bytes written, requiring extra looping in
Perl).
- And last but not least I'm using IO::Select to check with can_write
and a 0.050 s timeout on the pipe file handle.
This all seems to work, but is not as fast as without the non-blocking
stuff. So I'm wondering: is there a better way to do these kind of
things in the world of Gtk2-Perl, maybe with some support from Glib?
I'd rather create another process/thread and do the computations there.
You can communicate the status to the gtk ui thread using a pipe or
something that works with glib main loop.
Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]