… | |
… | |
241 | my $cb; |
241 | my $cb; |
242 | |
242 | |
243 | while () { |
243 | while () { |
244 | eval { |
244 | eval { |
245 | while () { |
245 | while () { |
|
|
246 | # &{&_pool_1 or &terminate}; # crashes, would be ~5% faster |
246 | $cb = &_pool_1 |
247 | $cb = &_pool_1 |
247 | or return; |
248 | or &terminate; |
248 | |
|
|
249 | &$cb; |
249 | &$cb; |
250 | |
|
|
251 | return if &_pool_2; |
|
|
252 | |
|
|
253 | undef $cb; |
250 | undef $cb; |
|
|
251 | &terminate if &_pool_2; |
254 | schedule; |
252 | &schedule; |
255 | } |
253 | } |
256 | }; |
254 | }; |
257 | |
255 | |
258 | warn $@ if $@; |
256 | warn $@ if $@; |
259 | } |
257 | } |
260 | } |
258 | } |
261 | |
259 | |
262 | sub async_pool(&@) { |
260 | sub async_pool(&@) { |
263 | # this is also inlined into the unlock_scheduler |
261 | # this is also inlined into the unlock_scheduler |
264 | my $coro = (pop @async_pool) || new Coro \&pool_handler;; |
262 | my $coro = (pop @async_pool) || new Coro \&pool_handler; |
265 | |
263 | |
266 | $coro->{_invoke} = [@_]; |
264 | $coro->{_invoke} = [@_]; |
267 | $coro->ready; |
265 | $coro->ready; |
268 | |
266 | |
269 | $coro |
267 | $coro |