POE::Component::ResourcePool::Resource::Collection - A collection of valeus to be shared (e.g. handles).
use POE::Component::ResourcePool::Resource::Collection; my $collection = POE::Component::ResourcePool::Resource::Collection->new( values => [ $handle1, $handle2, $handle3 ], ); # ... my $pool = POE::Component::ResourcePool->new( resources => { handles => $collection, }, ); $pool->request( params => { handles => $how_many, }, ... );
This resource allows the sharing of values from a collection in a round the robin fashion.
It is useful for e.g. limiting the number of database handles to a certain bound, but unlike the semaphore will pool the actual values instead of just counting.
The parameter to the request can be a number denoting how many values are required, with 1 being the default.
Unlike the semaphore resource could_allocate is not strict, and will always return true even if the count is bigger than the initial value list's size. This is to facilitate editing of the value collection array yourself.
could_allocate
If you modify the values attribute be sure to call notify_all_pools in order to check for potentially affected requests.
values
notify_all_pools
Note that you cannot reliably remove values from the values array because currently allocated values are not found in the list, but will be added later.
Subclassing this class with additional value tracking semantics should help alleviate any issues due to this.
If there are enough values in values to satisfy the count (defaults to 1) then these items are return.
Otherwise allocation will fail.
Splices the allocated values out of the values array.
Pushes the allocated values to the end of the values array.
An array reference of values to be allocated.
Duplicate values are treated as separate values, and will not be checked for (this is a feature).
To install POE::Component::ResourcePool, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::ResourcePool
CPAN shell
perl -MCPAN -e shell install POE::Component::ResourcePool
For more information on module installation, please visit the detailed CPAN module installation guide.