… | |
… | |
253 | |
253 | |
254 | my $destroy_guard = Guard::guard { |
254 | my $destroy_guard = Guard::guard { |
255 | $on_destroy->() |
255 | $on_destroy->() |
256 | if $on_destroy; |
256 | if $on_destroy; |
257 | }; |
257 | }; |
258 | |
|
|
259 | my $busy;#d# |
|
|
260 | |
258 | |
261 | $template |
259 | $template |
262 | ->require ("AnyEvent::Fork::RPC::" . ($arg{async} ? "Async" : "Sync")) |
260 | ->require ("AnyEvent::Fork::RPC::" . ($arg{async} ? "Async" : "Sync")) |
263 | ->eval (' |
261 | ->eval (' |
264 | my ($magic0, $magic1) = @_; |
262 | my ($magic0, $magic1) = @_; |
… | |
… | |
344 | |
342 | |
345 | my $job = shift @queue; |
343 | my $job = shift @queue; |
346 | my $ocb = pop @$job; |
344 | my $ocb = pop @$job; |
347 | |
345 | |
348 | $proc->[2]->(@$job, sub { |
346 | $proc->[2]->(@$job, sub { |
349 | --$busy; warn "busy now $busy\n";#d# |
|
|
350 | # reduce queue counter |
347 | # reduce queue counter |
351 | --$pool[$_][0] |
348 | --$pool[$_][0] |
352 | or ++$nidle > $idle |
349 | or ++$nidle > $idle |
353 | or $want_stop->(); |
350 | or $want_stop->(); |
354 | |
351 | |
… | |
… | |
385 | while @pool < $idle; |
382 | while @pool < $idle; |
386 | |
383 | |
387 | sub { |
384 | sub { |
388 | $shutdown_guard if 0; # keep it alive |
385 | $shutdown_guard if 0; # keep it alive |
389 | |
386 | |
390 | ++$busy;#d# |
|
|
391 | |
|
|
392 | $start->() |
387 | $start->() |
393 | unless @pool; |
388 | unless @pool; |
394 | |
389 | |
395 | push @queue, [@_]; |
390 | push @queue, [@_]; |
396 | $scheduler->(); |
391 | $scheduler->(); |