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.23 by root, Mon Jun 22 11:17:03 2009 UTC vs.
Revision 1.24 by root, Wed Jul 8 02:01:12 2009 UTC

39 39
40use Glib (); 40use Glib ();
41 41
42our $mainloop = Glib::MainContext->default; 42our $mainloop = Glib::MainContext->default;
43 43
44my %io_cond = (
45 r => ["in" , "hup"],
46 w => ["out", "hup"],
47);
48
44sub io { 49sub io {
45 my ($class, %arg) = @_; 50 my ($class, %arg) = @_;
46 51
47 my $cb = $arg{cb}; 52 my $cb = $arg{cb};
53 my $fd = fileno $arg{fh};
54 defined $fd or $fd = $arg{fh};
48 55
49 my @cond; 56 my $source = add_watch Glib::IO
50 # some glibs need hup, others error with it, YMMV 57 $fd,
51 push @cond, "in", "hup" if $arg{poll} eq "r"; 58 $io_cond{$arg{poll}},
52 push @cond, "out", "hup" if $arg{poll} eq "w"; 59 sub { &$cb; 1 };
53 60
54 my $source = add_watch Glib::IO fileno $arg{fh}, \@cond, sub { &$cb; 1 };
55 bless \\$source, $class 61 bless \\$source, $class
56} 62}
57 63
58sub timer { 64sub timer {
59 my ($class, %arg) = @_; 65 my ($class, %arg) = @_;
88sub one_event { 94sub one_event {
89 $mainloop->iteration (1); 95 $mainloop->iteration (1);
90} 96}
91 97
92sub loop { 98sub loop {
93 $mainloop->iteration (1) while 1; # hackish, but w ehave no mainloop 99 # hackish, but we do not have a mainloop, just a maincontext
100 $mainloop->iteration (1) while 1;
94} 101}
95 102
961; 1031;
97 104
98=head1 SEE ALSO 105=head1 SEE ALSO

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines