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.2 by root, Thu Dec 1 18:56:18 2005 UTC vs.
Revision 1.3 by root, Thu Dec 1 22:04:50 2005 UTC

11); 11);
12 12
13sub io { 13sub io {
14 my ($class, %arg) = @_; 14 my ($class, %arg) = @_;
15 15
16 my $self = \%arg, $class; 16 my $self = bless \%arg, $class;
17 my $rcb = \$self->{cb}; 17 my $rcb = \$self->{cb};
18 18
19 my @cond; 19 my @cond;
20 push @cond, "in" if $self->{poll} =~ /r/i; 20 push @cond, "in" if $self->{poll} =~ /r/i;
21 push @cond, "out" if $self->{poll} =~ /w/i; 21 push @cond, "out" if $self->{poll} =~ /w/i;
30} 30}
31 31
32sub timer { 32sub timer {
33 my ($class, %arg) = @_; 33 my ($class, %arg) = @_;
34 34
35 my $self = \%arg, $class; 35 my $self = bless \%arg, $class;
36 my $cb = $self->{cb}; 36 my $cb = $self->{cb};
37 37
38 $self->{source} = add Glib::Timeout $self->{after} * 1000, sub { 38 $self->{source} = add Glib::Timeout $self->{after} * 1000, sub {
39 $cb->(); 39 $cb->();
40 0 40 0
43 $self 43 $self
44} 44}
45 45
46sub cancel { 46sub cancel {
47 my ($self) = @_; 47 my ($self) = @_;
48
49 return unless HASH:: eq ref $self;
50 48
51 remove Glib::Source delete $self->{source} if $self->{source}; 49 remove Glib::Source delete $self->{source} if $self->{source};
52 $self->{cb} = undef; 50 $self->{cb} = undef;
53 delete $self->{cb}; 51 delete $self->{cb};
54} 52}
60} 58}
61 59
62sub condvar { 60sub condvar {
63 my $class = shift; 61 my $class = shift;
64 62
65 bless \my $x, $class; 63 bless \my $x, AnyEvent::Impl::Glib::CondVar::
66} 64}
67 65
68sub broadcast { 66sub AnyEvent::Impl::Glib::CondVar::broadcast {
69 ${$_[0]}++ 67 ${$_[0]}++;
70} 68}
71 69
72sub wait { 70sub AnyEvent::Impl::Glib::CondVar::wait {
73 $maincontext->iteration (1) while !${$_[0]}; 71 $maincontext->iteration (1) while !${$_[0]};
74} 72}
75 73
76$AnyEvent::MODEL = __PACKAGE__; 74$AnyEvent::MODEL = __PACKAGE__;
77 75

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines