Re: Using Gtk2::Helper->add_watch() or Glib::IO->add_watch
- From: muppet <scott asofyet org>
- To: ofey aikon <ofey aikon gmail com>
- Cc: GTK2-Perl List <gtk-perl-list gnome org>
- Subject: Re: Using Gtk2::Helper->add_watch() or Glib::IO->add_watch
- Date: Tue, 23 Aug 2005 21:50:46 -0400
On Aug 23, 2005, at 8:30 PM, ofey aikon wrote:
That's quite possible. Win32 is infamous for its rather broken
pipes. One aspect of that is that pipes and network sockets behave
differently wrt select(), mostly in that pipes tend to be broken
while sockets work.
Well, after spending a bit more time on this, I concluded that using
pipes on win32 is definitely impossible. So I decided to model the
functionality that I need using threads instead. I have re-written the
FAQ example to use threads instead of pipes. The inspiration of course
was from muppet's code at
http://mail.gnome.org/archives/gtk-perl-list/2003-November/
msg00028.html
That example predates some other important developments in threading
support...
You want to have:
use Gtk2 '-init', '-threads-init';
The -threads-init import option is equalivent to calling
Gtk2::Gdk::Threads->init(). This makes the calls to
Gtk2::Gdk::Threads->enter() and Gtk2::Gdk::Threads->leave() actually
have effect for wrapping calls to gui functions from child threads;
see the C reference docs for gdk_threads_enter() and gdk_threads_leave
().
You'll also want to call Glib::Object->set_threadsafe (TRUE); before
doing much of anything; this enables object tracking within the
bindings, to avoid the "object destroyed out from under you"
problem. The bindings must be built with thread support, which is
the default.
Note, however, that i have not personally played with this thread-
safety stuff to any degree, so YMMV.
--
And then mama would throw the live crawdads in the boilin' water.
And one day I decided I'd make my own crawdads. So I threw the
crawdads in the pot, but without any water. It was just like makin'
popcorn.
- Ear-bending cellmate, "Raising Arizona"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]