Async::ResourcePool - Resource pooling for asynchronous programs.
This module implements the simple functionality of creating a source pool for event-based/asynchronous programs. It provides consumers with the ability to have some code execute whenever a resource happens to be ready. Further, it allows resources to be categorized (by label) and limited as such.
The factory for generating the resource. The factory is a subroutine reference which accepts an instance of this object and a callback as a reference. The callback, to be invoked when the resource has been allocated.
If no resource could be allocated due to error, then undef should be supplied with the second argument being a string describing the failure.
The number of resources to create per label.
Optional.
A flag indicating whether or not this pool currently has a wait queue.
Read-only.
A flag indicating whether or not this pool has any idle resources available.
The current size of the pool.
Request a lease, with a callback invoked when the resource becomes available. The first argument of the callback will be the resource, if it was able to be granted, the second argument of the callback will be the error message, which will only be defined if first argument is not.
Return a resource to the pool. This will signal any waiters which haven't yet received a callback.
Invalidate a resource, signaling that it is no longer valid and no longer can be distributed by this pool. This will allocate another resource if there are any waiters.
To install Async::ResourcePool, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Async::ResourcePool
CPAN shell
perl -MCPAN -e shell install Async::ResourcePool
For more information on module installation, please visit the detailed CPAN module installation guide.