pool resource
extra arguments to pass to the resource factory during initialization
Set of all available resources
Map of active borrow events
Store of borrowed pool resources
Event emitter to broadcast pool events
Queue of active events
A function to calculate a hash string for the specified arguments
The maximum number of resources that the pool can contain
Handler: taking some resource via borrow
methods
Handler: clearing of all pool resources
Handler: releasing of some resource
Handler: taking some resource via take
methods
A function to destroy one resource from the pool
A factory to create a new resource for the pool.
The function take arguments that are passed to takeOrCreate
, borrowAndCreate
, etc.
Store of pool resources
Set of all unavailable resources
Number of available resources that are stored in the pool
Number of resources that are stored in the pool
Borrows an available resource from the pool. The passed arguments will be used to calculate a resource hash. Also, they will be provided to hook handlers.
When a resource is borrowed, it won’t be dropped from the pool. I.e. you can share it with other consumers. Mind, you can’t take this resource from the pool when it’s borrowed.
The returned result is wrapped with a structure that contains methods to release or drop this resource. If the pool is empty, the structure value field will be nullish.
Borrows an available resource from the pool. The passed arguments will be used to calculate a resource hash. Also, they will be provided to hook handlers.
When a resource is borrowed, it won’t be dropped from the pool. I.e. you can share it with other consumers. Mind, you can’t take this resource from the pool when it’s borrowed.
The returned result is wrapped with a structure that contains methods to release or drop this resource. If the pool is empty, it creates a new resource and returns it.
Returns a promise with a borrowed resource from the pull. The passed arguments will be used to calculate a resource hash. Also, they will be provided to hook handlers.
When a resource is borrowed, it won’t be dropped from the pool. I.e. you can share it with other consumers. Mind, you can’t take this resource from the pool when it’s borrowed.
The returned result is wrapped with a structure that contains methods to release or drop this resource. If the pool is empty, the promise will wait till it release.
Checks if you can borrow a resource. The passed arguments will be used to calculate a resource hash.
Returns how many elements of the specified kind you can take. The method takes arguments that will be used to calculate a resource hash.
Clears the pool, i.e. drops all created resource. The method takes arguments that will be provided to hook handlers.
Creates a resource and stores it in the pool. The method takes arguments that will be provided to a resource factory.
Releases the specified resource. The method takes arguments that will be provided to hook handlers.
Returns an available resource from the pool. The passed arguments will be used to calculate a resource hash. Also, they will be provided to hook handlers.
The returned result is wrapped with a structure that contains methods to release or drop this resource. If the pool is empty, the structure value field will be nullish.
Returns an available resource from the pool. The passed arguments will be used to calculate a resource hash. Also, they will be provided to hook handlers.
The returned result is wrapped with a structure that contains methods to release or drop this resource. If the pool is empty, it creates a new resource and returns it.
Returns a promise with an available resource from the pull. The passed arguments will be used to calculate a resource hash. Also, they will be provided to hook handlers.
The returned result is wrapped with a structure that contains methods to release or drop this resource. If the pool is empty, the promise will wait till it release.
Wraps the specified resource and returns the wrapper
Implementation of an object pool structure