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.14 by root, Sun Oct 26 16:22:38 2014 UTC vs.
Revision 1.17 by root, Thu Oct 27 07:27:56 2022 UTC

46This module uses processes created via L<AnyEvent::Fork> (or 46This module uses processes created via L<AnyEvent::Fork> (or
47L<AnyEvent::Fork::Remote>) and the RPC protocol implement in 47L<AnyEvent::Fork::Remote>) and the RPC protocol implement in
48L<AnyEvent::Fork::RPC> to create a load-balanced pool of processes that 48L<AnyEvent::Fork::RPC> to create a load-balanced pool of processes that
49handles jobs. 49handles jobs.
50 50
51Understanding of L<AnyEvent::Fork> is helpful but not critical to be able 51Understanding L<AnyEvent::Fork> is helpful but not required to use this
52to use this module, but a thorough understanding of L<AnyEvent::Fork::RPC> 52module, but a thorough understanding of L<AnyEvent::Fork::RPC> is, as
53is, as it defines the actual API that needs to be implemented in the 53it defines the actual API that needs to be implemented in the worker
54worker processes. 54processes.
55 55
56=head1 PARENT USAGE 56=head1 PARENT USAGE
57 57
58To create a pool, you first have to create a L<AnyEvent::Fork> object - 58To create a pool, you first have to create a L<AnyEvent::Fork> object -
59this object becomes your template process. Whenever a new worker process 59this object becomes your template process. Whenever a new worker process
94# in the hope of not colliding. yes, I don't like it either, 94# in the hope of not colliding. yes, I don't like it either,
95# but didn't come up with an obviously better alternative. 95# but didn't come up with an obviously better alternative.
96my $magic0 = ':t6Z@HK1N%Dx@_7?=~-7NQgWDdAs6a,jFN=wLO0*jD*1%P'; 96my $magic0 = ':t6Z@HK1N%Dx@_7?=~-7NQgWDdAs6a,jFN=wLO0*jD*1%P';
97my $magic1 = '<~53rexz.U`!]X[A235^"fyEoiTF\T~oH1l/N6+Djep9b~bI9`\1x%B~vWO1q*'; 97my $magic1 = '<~53rexz.U`!]X[A235^"fyEoiTF\T~oH1l/N6+Djep9b~bI9`\1x%B~vWO1q*';
98 98
99our $VERSION = 1.1; 99our $VERSION = 1.3;
100 100
101=item my $pool = AnyEvent::Fork::Pool::run $fork, $function, [key => value...] 101=item my $pool = AnyEvent::Fork::Pool::run $fork, $function, [key => value...]
102 102
103The traditional way to call the pool creation function. But it is way 103The traditional way to call the pool creation function. But it is way
104cooler to call it in the following way: 104cooler to call it in the following way:
397 397
398 last; 398 last;
399 } 399 }
400 } 400 }
401 } elsif ($shutdown) { 401 } elsif ($shutdown) {
402 @pool = (); 402 undef $_->[2]
403 for @pool;
404
403 undef $start_w; 405 undef $start_w;
404 undef $start_worker; # frees $destroy_guard reference 406 undef $start_worker; # frees $destroy_guard reference
405 407
406 $stop_worker->($pool[0]) 408 $stop_worker->($pool[0])
407 while $nidle; 409 while $nidle;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines