Copyright © 2013-2016 Alexei Krasnopolski
Version: 1.0.3
Introduced in: 2013-03-21
Authors: Alexei Krasnopolski (krasnop@bellsouth.net) [web site: http://krasnopolski.org/].
add/1 | Adds one more resource to pool (as an idle resource). |
borrow/1 | Borrows resource from pool for client use. |
clear/1 | Disposes all resources from the pool. |
close/1 | Disposes all resources from the pool and close the pool (shut down generic server). |
get_num_active/1 | Returns number of active (busy) resource in pool. |
get_num_idle/1 | Returns number of idle (ready to use) resource in pool. |
get_number/1 | Returns total number of resource in pool. |
invalidate/2 | Invalidates resource - makes it ready to dispose. |
new/3 | Creates and runs new generic server for resource_pool with registered name Pool_name . |
new/4 | Creates and runs new generic server for resource_pool with registered name Pool_name . |
return/2 | Returns resource to pool after client does not need it more. |
new(Pool_name::atom(), Factory_module::atom(), Resource_metadata::term()) -> {ok, Resource} | ignore | {error, Error}
Creates and runs new generic server for resource_pool with registered name Pool_name
. The new resource pool will use
Factory_module as a resource factory and Resource_metadata as a metadata to create a new resource.
new(Pool_name::atom(), Factory_module::atom(), Resource_metadata::term(), Options::[{Key, Value}]) -> {ok, Resource} | ignore | {error, Error}
Creates and runs new generic server for resource_pool with registered name Pool_name
. The new resource pool will use
Factory_module as a resource factory and Resource_metadata as a metadata to create a new resource.
The available options are:
{max_active, integer()}
max_active
is reached, the pool is said to be exhausted.
The default setting for this parameter is 8.
{max_idle, integer()}
max_active
.
{min_idle, integer()}
{test_on_borrow, boolean()}
false.
{test_on_return, boolean()}
false.
{fifo, boolean()}
false.
{when_exhausted_action, (fail | block | grow)}
borrow
function when the pool is exhausted:
borrow
will block for at most that many milliseconds,
after which an error will be returned. If max_wait is non-positive,
the borrow
function will block infinitely.when_exhausted_action
setting is block
and
the default max_wait
setting is infinity. By default, therefore, borrow
will
block infinitely until an idle instance becomes available.
{max_wait, (integer() | infinity)}
borrow
function
is invoked, the pool is exhausted (the maximum number
of "active" resource instances has been reached) and when_exhausted_action equals block
.
{max_idle_time, (integer() | infinity)}
borrow(Pool_name::atom() | pid()) -> Resource | {error, Reason}
Borrows resource from pool for client use.
return(Pool_name::atom(), Resource::term()) -> ok
Returns resource to pool after client does not need it more.
add(Pool_name::atom()) -> ok
Adds one more resource to pool (as an idle resource).
invalidate(Pool_name::atom(), Resource::term()) -> ok
Invalidates resource - makes it ready to dispose.
get_num_active(Pool_name::atom()) -> integer()
Returns number of active (busy) resource in pool.
get_num_idle(Pool_name::atom()) -> integer()
Returns number of idle (ready to use) resource in pool.
get_number(Pool_name::atom()) -> integer()
Returns total number of resource in pool.
clear(Pool_name::atom()) -> ok
Disposes all resources from the pool.
close(Pool_name::atom()) -> ok
Disposes all resources from the pool and close the pool (shut down generic server).
Generated by EDoc, Feb 14 2016, 02:21:40.