… | |
… | |
129 | bless $w, $class |
129 | bless $w, $class |
130 | }; |
130 | }; |
131 | *{ $flavour } = $coronew; |
131 | *{ $flavour } = $coronew; |
132 | *{"do_$flavour"} = sub { |
132 | *{"do_$flavour"} = sub { |
133 | unshift @_, Coro::Event::; |
133 | unshift @_, Coro::Event::; |
134 | my $e = &$coronew->next; |
134 | @_ = &$coronew; |
135 | $e->cancel; # $e === $e->w |
135 | &Coro::schedule while &_next; |
136 | $e |
136 | $_[0]->cancel; |
|
|
137 | &_event |
137 | }; |
138 | }; |
138 | } |
139 | } |
139 | |
140 | |
140 | # do schedule in perl to avoid forcign a stack allocation. |
141 | # do schedule in perl to avoid forcing a stack allocation. |
141 | # this is about 10% slower, though. |
142 | # this is about 10% slower, though. |
142 | sub next($) { |
143 | sub next($) { |
143 | &Coro::schedule while &_next; |
144 | &Coro::schedule while &_next; |
144 | |
145 | |
145 | $_[0] |
146 | &_event |
146 | } |
147 | } |
147 | |
148 | |
148 | sub Coro::Event::w { $_[0] } |
149 | sub Coro::Event::w { $_[0] } |
149 | sub Coro::Event::prio { $_[0]{Coro::Event}[3] } |
150 | sub Coro::Event::prio { $_[0]{Coro::Event}[3] } |
150 | sub Coro::Event::hits { $_[0]{Coro::Event}[4] } |
151 | sub Coro::Event::hits { $_[0]{Coro::Event}[4] } |