ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Impl/Glib.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Impl/Glib.pm (file contents):
Revision 1.3 by root, Thu Dec 1 22:04:50 2005 UTC vs.
Revision 1.4 by root, Fri Dec 30 01:28:31 2005 UTC

3use Glib (); 3use Glib ();
4 4
5my $maincontext = Glib::MainContext->default; 5my $maincontext = Glib::MainContext->default;
6 6
7my %RWE = ( 7my %RWE = (
8 hup => 'rw',
8 in => 'r', 9 in => 'r',
9 out => 'w', 10 out => 'w',
10 pri => 'e', 11 pri => 'e',
11); 12);
12 13
14 my ($class, %arg) = @_; 15 my ($class, %arg) = @_;
15 16
16 my $self = bless \%arg, $class; 17 my $self = bless \%arg, $class;
17 my $rcb = \$self->{cb}; 18 my $rcb = \$self->{cb};
18 19
19 my @cond; 20 # some glibs need hup, others error with it, YMMV
20 push @cond, "in" if $self->{poll} =~ /r/i; 21 push @cond, "in", "hup" if $self->{poll} =~ /r/i;
21 push @cond, "out" if $self->{poll} =~ /w/i; 22 push @cond, "out", "hup" if $self->{poll} =~ /w/i;
22 push @cond, "pri" if $self->{poll} =~ /e/i; 23 push @cond, "pri" if $self->{poll} =~ /e/i;
23 24
24 $self->{source} = add_watch Glib::IO fileno $self->{fh}, \@cond, sub { 25 $self->{source} = add_watch Glib::IO fileno $self->{fh}, \@cond, sub {
25 $$rcb->(join "", map $RWE{$_}, @{ $_[1] }); 26 $$rcb->(join "", map $RWE{$_}, @{ $_[1] });
26 ! ! $$rcb 27 ! ! $$rcb
27 }; 28 };
71 $maincontext->iteration (1) while !${$_[0]}; 72 $maincontext->iteration (1) while !${$_[0]};
72} 73}
73 74
74$AnyEvent::MODEL = __PACKAGE__; 75$AnyEvent::MODEL = __PACKAGE__;
75 76
761; 771
77 78

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines