… | |
… | |
100 | # in the hope of not colliding. yes, I don't like it either, |
100 | # in the hope of not colliding. yes, I don't like it either, |
101 | # but didn't come up with an obviously better alternative. |
101 | # but didn't come up with an obviously better alternative. |
102 | my $magic0 = ':t6Z@HK1N%Dx@_7?=~-7NQgWDdAs6a,jFN=wLO0*jD*1%P'; |
102 | 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*'; |
103 | my $magic1 = '<~53rexz.U`!]X[A235^"fyEoiTF\T~oH1l/N6+Djep9b~bI9`\1x%B~vWO1q*'; |
104 | |
104 | |
105 | our $VERSION = 0.1; |
105 | our $VERSION = 1.1; |
106 | |
106 | |
107 | =item my $pool = AnyEvent::Fork::Pool::run $fork, $function, [key => value...] |
107 | =item my $pool = AnyEvent::Fork::Pool::run $fork, $function, [key => value...] |
108 | |
108 | |
109 | The traditional way to call the pool creation function. But it is way |
109 | The traditional way to call the pool creation function. But it is way |
110 | cooler to call it in the following way: |
110 | cooler to call it in the following way: |
… | |
… | |
537 | deems this useful. For example, after executing a job, one could check |
537 | deems this useful. For example, after executing a job, one could check |
538 | the process size or the number of jobs handled so far, and if either is |
538 | the process size or the number of jobs handled so far, and if either is |
539 | too high, the worker could ask to get retired, to avoid memory leaks to |
539 | too high, the worker could ask to get retired, to avoid memory leaks to |
540 | accumulate. |
540 | accumulate. |
541 | |
541 | |
|
|
542 | Example: retire a worker after it has handled roughly 100 requests. |
|
|
543 | |
|
|
544 | my $count = 0; |
|
|
545 | |
|
|
546 | sub my::worker { |
|
|
547 | |
|
|
548 | ++$count == 100 |
|
|
549 | and AnyEvent::Fork::Pool::retire (); |
|
|
550 | |
|
|
551 | ... normal code goes here |
|
|
552 | } |
|
|
553 | |
542 | =back |
554 | =back |
543 | |
555 | |
544 | =head1 POOL PARAMETERS RECIPES |
556 | =head1 POOL PARAMETERS RECIPES |
545 | |
557 | |
546 | This section describes some recipes for pool paramaters. These are mostly |
558 | This section describes some recipes for pool paramaters. These are mostly |