Event loop, non-blocking i/o
- From: Martin Junius <mj+gnome ml m-j-s net>
- To: gtk-perl-list gnome org
- Subject: Event loop, non-blocking i/o
- Date: Sat, 11 Dec 2004 19:30:17 +0100
Hi all!
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?
Regards,
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]