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,

                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.

If you modify the values attribute be sure to call notify_all_pools in order to check for potentially affected requests.

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).