ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-Fork-Pool/Pool.pm
(Generate patch)

Comparing AnyEvent-Fork-Pool/Pool.pm (file contents):
Revision 1.6 by root, Sun Apr 21 11:17:02 2013 UTC vs.
Revision 1.7 by root, Sun Apr 21 12:03:02 2013 UTC

328 $proc->[0] 328 $proc->[0]
329 or --$nidle; 329 or --$nidle;
330 330
331 Array::Heap::splice_heap_idx @pool, $proc->[1] 331 Array::Heap::splice_heap_idx @pool, $proc->[1]
332 if defined $proc->[1]; 332 if defined $proc->[1];
333
334 @$proc = 0; # tell others to leave it be
333 }; 335 };
334 336
335 $want_start = sub { 337 $want_start = sub {
336 undef $stop_w; 338 undef $stop_w;
337 339
356 }; 358 };
357 359
358 $scheduler = sub { 360 $scheduler = sub {
359 if (@queue) { 361 if (@queue) {
360 while (@queue) { 362 while (@queue) {
363 @pool or $start_worker->();
364
361 my $proc = $pool[0]; 365 my $proc = $pool[0];
362 366
363 if ($proc->[0] < $load) { 367 if ($proc->[0] < $load) {
364 # found free worker, increase load 368 # found free worker, increase load
365 unless ($proc->[0]++) { 369 unless ($proc->[0]++) {
383 or $want_stop->(); 387 or $want_stop->();
384 388
385 Array::Heap::adjust_heap_idx @pool, $proc->[1] 389 Array::Heap::adjust_heap_idx @pool, $proc->[1]
386 if defined $proc->[1]; 390 if defined $proc->[1];
387 391
392 &$ocb;
393
388 $scheduler->(); 394 $scheduler->();
389
390 &$ocb;
391 }); 395 });
392 } else { 396 } else {
393 $want_start->() 397 $want_start->()
394 unless @pool >= $max; 398 unless @pool >= $max;
395 399
513having only one worker is best, for example, when you read or write big 517having only one worker is best, for example, when you read or write big
514files at maixmum speed, as a second worker will increase seek times. 518files at maixmum speed, as a second worker will increase seek times.
515 519
516=back 520=back
517 521
522=head1 EXCEPTIONS
523
524The same "policy" as with L<AnyEvent::Fork::RPC> applies - exceptins will
525not be caught, and exceptions in both worker and in callbacks causes
526undesirable or undefined behaviour.
527
518=head1 SEE ALSO 528=head1 SEE ALSO
519 529
520L<AnyEvent::Fork>, to create the processes in the first place. 530L<AnyEvent::Fork>, to create the processes in the first place.
521 531
522L<AnyEvent::Fork::RPC>, which implements the RPC protocol and API. 532L<AnyEvent::Fork::RPC>, which implements the RPC protocol and API.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines