1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | AnyEvent::Fork::Pool - simple process pool manager on top of AnyEvent::Fork |
3 | AnyEvent::Fork::Pool - simple process pool manager on top of AnyEvent::Fork |
4 | |
|
|
5 | THE API IS NOT FINISHED, CONSIDER THIS AN ALPHA RELEASE |
|
|
6 | |
4 | |
7 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
8 | |
6 | |
9 | use AnyEvent; |
7 | use AnyEvent; |
10 | use AnyEvent::Fork::Pool; |
8 | use AnyEvent::Fork::Pool; |
… | |
… | |
43 | |
41 | |
44 | $finish->recv; |
42 | $finish->recv; |
45 | |
43 | |
46 | =head1 DESCRIPTION |
44 | =head1 DESCRIPTION |
47 | |
45 | |
48 | This module uses processes created via L<AnyEvent::Fork> and the RPC |
46 | This module uses processes created via L<AnyEvent::Fork> (or |
49 | protocol implement in L<AnyEvent::Fork::RPC> to create a load-balanced |
47 | L<AnyEvent::Fork::Remote>) and the RPC protocol implement in |
50 | pool of processes that handles jobs. |
48 | L<AnyEvent::Fork::RPC> to create a load-balanced pool of processes that |
|
|
49 | handles jobs. |
51 | |
50 | |
52 | Understanding of L<AnyEvent::Fork> is helpful but not critical to be able |
51 | Understanding of L<AnyEvent::Fork> is helpful but not critical to be able |
53 | to use this module, but a thorough understanding of L<AnyEvent::Fork::RPC> |
52 | to use this module, but a thorough understanding of L<AnyEvent::Fork::RPC> |
54 | is, as it defines the actual API that needs to be implemented in the |
53 | is, as it defines the actual API that needs to be implemented in the |
55 | worker processes. |
54 | worker processes. |
56 | |
|
|
57 | =head1 EXAMPLES |
|
|
58 | |
55 | |
59 | =head1 PARENT USAGE |
56 | =head1 PARENT USAGE |
60 | |
57 | |
61 | To create a pool, you first have to create a L<AnyEvent::Fork> object - |
58 | To create a pool, you first have to create a L<AnyEvent::Fork> object - |
62 | this object becomes your template process. Whenever a new worker process |
59 | this object becomes your template process. Whenever a new worker process |
… | |
… | |
100 | # in the hope of not colliding. yes, I don't like it either, |
97 | # in the hope of not colliding. yes, I don't like it either, |
101 | # but didn't come up with an obviously better alternative. |
98 | # but didn't come up with an obviously better alternative. |
102 | my $magic0 = ':t6Z@HK1N%Dx@_7?=~-7NQgWDdAs6a,jFN=wLO0*jD*1%P'; |
99 | my $magic0 = ':t6Z@HK1N%Dx@_7?=~-7NQgWDdAs6a,jFN=wLO0*jD*1%P'; |
103 | my $magic1 = '<~53rexz.U`!]X[A235^"fyEoiTF\T~oH1l/N6+Djep9b~bI9`\1x%B~vWO1q*'; |
100 | my $magic1 = '<~53rexz.U`!]X[A235^"fyEoiTF\T~oH1l/N6+Djep9b~bI9`\1x%B~vWO1q*'; |
104 | |
101 | |
105 | our $VERSION = 0.1; |
102 | our $VERSION = 1.1; |
106 | |
103 | |
107 | =item my $pool = AnyEvent::Fork::Pool::run $fork, $function, [key => value...] |
104 | =item my $pool = AnyEvent::Fork::Pool::run $fork, $function, [key => value...] |
108 | |
105 | |
109 | The traditional way to call the pool creation function. But it is way |
106 | The traditional way to call the pool creation function. But it is way |
110 | cooler to call it in the following way: |
107 | cooler to call it in the following way: |
… | |
… | |
606 | |
603 | |
607 | =head1 SEE ALSO |
604 | =head1 SEE ALSO |
608 | |
605 | |
609 | L<AnyEvent::Fork>, to create the processes in the first place. |
606 | L<AnyEvent::Fork>, to create the processes in the first place. |
610 | |
607 | |
|
|
608 | L<AnyEvent::Fork::Remote>, likewise, but helpful for remote processes. |
|
|
609 | |
611 | L<AnyEvent::Fork::RPC>, which implements the RPC protocol and API. |
610 | L<AnyEvent::Fork::RPC>, which implements the RPC protocol and API. |
612 | |
611 | |
613 | =head1 AUTHOR AND CONTACT INFORMATION |
612 | =head1 AUTHOR AND CONTACT INFORMATION |
614 | |
613 | |
615 | Marc Lehmann <schmorp@schmorp.de> |
614 | Marc Lehmann <schmorp@schmorp.de> |