Re: Infinite Loop with Glib::IO->add_watch()
- From: "A. Pagaltzis" <pagaltzis gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: Infinite Loop with Glib::IO->add_watch()
- Date: Wed, 8 Sep 2004 10:28:02 +0200
* Mike Schilli <b2b perlmeister com> [2004-09-08 10:15]:
when I'm using add_watch() to register a watch on a filehandle,
the callback associated with it is called infinitely:
Glib::IO->add_watch(fileno(\*READHANDLE),
'in', sub { print "got something!\n"; 1; });
even if there's only one event. Is there a way to prevent this without
returning 0 in the callback and therefore disabling the watch?
The Glib docs say that 'in' aka G_IO_IN means "There is data to
read.", and since you're not reading any data in your callback,
after the callback returns, there's still data to be read, and so
it gets called again.
This is not a Gtk2-Perl issue, it's how Glib works (and
incidentally, just how select(3) has always worked as well, so
there's precedent for the semantics in the Unix world, at least).
Regards,
--
Aristotle
"If you can't laugh at yourself, you don't take life seriously enough."
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]