ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Event/Event.pm
(Generate patch)

Comparing Coro/Event/Event.pm (file contents):
Revision 1.2 by root, Fri Aug 17 01:45:39 2001 UTC vs.
Revision 1.3 by root, Fri Aug 17 03:33:00 2001 UTC

81method. This is less efficient then calling the constructor once and the 81method. This is less efficient then calling the constructor once and the
82next method often, but it does save typing sometimes. 82next method often, but it does save typing sometimes.
83 83
84=cut 84=cut
85 85
86#sub std_cb {
87# my $w = $_[0]->w;
88# my $q = $w->private;
89# $q->[1] = $_[0];
90# if ($q->[0]) { # somebody waiting?
91# $q->[0]->ready;
92# &Coro::schedule;
93# } else {
94# $w->stop;
95# }
96#}
97
98for my $flavour (qw(idle var timer io signal)) { 86for my $flavour (qw(idle var timer io signal)) {
99 push @EXPORT, "do_$flavour"; 87 push @EXPORT, "do_$flavour";
100 my $new = \&{"Event::$flavour"}; 88 my $new = \&{"Event::$flavour"};
101 my $class = "Coro::Event::$flavour"; 89 my $class = "Coro::Event::$flavour";
102 my $type = $flavour eq "io" ? 1 : 0; 90 my $type = $flavour eq "io" ? 1 : 0;
125 $e; 113 $e;
126 }; 114 };
127} 115}
128 116
129# double calls to avoid stack-cloning ;() 117# double calls to avoid stack-cloning ;()
130# is about 20% slower, though. 118# is about 10% slower, though.
131sub next($) { 119sub next($) {
132 &_next0; 120 &Coro::schedule if &_next; $_[0];
133 &Coro::schedule;
134 &_next1;
135} 121}
136 122
137#sub next {
138# my $w = $_[0];
139# my $q = $w->private;
140# if ($q->[1]) { # event waiting?
141# $w->again unless $w->is_cancelled;
142# } elsif ($q->[0]) {
143# croak "only one coroutine can wait for an event";
144# } else {
145# local $q->[0] = $Coro::current;
146# &Coro::schedule;
147# }
148# pop @$q;
149#}
150
151sub Coro::Event::Ev::w { $_[0][2] } 123sub Coro::Event::w { $_[0]{Coro::Event}[2] }
152sub Coro::Event::Ev::got { $_[0][3] } 124sub Coro::Event::got { $_[0]{Coro::Event}[3] }
153sub Coro::Event::Ev::prio { croak "prio not supported yet, please mail to pcg\@goof.com" } 125sub Coro::Event::prio { croak "prio not supported yet, please mail to pcg\@goof.com" }
154sub Coro::Event::Ev::hits { croak "prio not supported yet, please mail to pcg\@goof.com" } 126sub Coro::Event::hits { croak "prio not supported yet, please mail to pcg\@goof.com" }
155 127
156=item sweep 128=item sweep
157 129
158Similar to Event::one_event and Event::sweep: The idle task is called once 130Similar to Event::one_event and Event::sweep: The idle task is called once
159(this has the effect of jumping back into the Event loop once to serve new 131(this has the effect of jumping back into the Event loop once to serve new

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines