… | |
… | |
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 |