Resource pool v1.0.3 ResourcePool View Source
Facade for resource pool.
Link to this section Summary
Functions
Adds one more resource to pool (as an idle resource).
Borrows resource from pool. Returns resource pid for client use.
Disposes all resources from the pool.
Disposes all resources from the pool and close the pool (shut down generic server).
Returns number of active (busy) resources in pool.
Returns number of idle (ready to use) resources in pool.
Returns total number of resources in pool as a tuple {active, idle}.
Invalidates resource - makes it ready to dispose.
Creates and runs new generic server for ResourcePool 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.
Creates and runs new generic server for ResourcePool 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.
options defines behaviour of the pool.
The available options are
The function sends resource to the pool's idle container after client does not need it any more.
Link to this section Functions
Specs
Adds one more resource to pool (as an idle resource).
Specs
Borrows resource from pool. Returns resource pid for client use.
Specs
Disposes all resources from the pool.
Specs
Disposes all resources from the pool and close the pool (shut down generic server).
Specs
Returns number of active (busy) resources in pool.
Specs
Returns number of idle (ready to use) resources in pool.
Specs
Returns total number of resources in pool as a tuple {active, idle}.
Specs
Invalidates resource - makes it ready to dispose.
Specs
Creates and runs new generic server for ResourcePool 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.
Specs
Creates and runs new generic server for ResourcePool 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.
options defines behaviour of the pool.
The available options are:
max_active: integer()- defines the maximum number of resource instances that can be allocated by the pool at a given time. If non-positive, there is no limit to the number of instances that can be managed by the pool at one time. Whenmax_activeis reached, the pool is said to be exhausted. The default setting for this parameter is 8.max_idle: integer()defines the maximum number of objects that can sit idle in the pool at any time. If negative, there is no limit to the number of objects that may be idle at one time. The default setting for this parameter equalsmax_active.min_idle: integer()defines the minimum number of "sleeping" instances in the pool. Default value is 0.test_on_borrow: boolean()If true the pool will attempt to validate each resource before it is returned from the borrow function (Using the provided resource factory's validate function). Instances that fail to validate will be dropped from the pool, and a different object will be borrowed. The default setting for this parameter isfalse.test_on_return: boolean()If true the pool will attempt to validate each resource instance before it is returned to the pool in the return function (Using the provided resource factory's validate function). Objects that fail to validate will be dropped from the pool. The default setting for this option isfalse.fifo: boolean()The pool can act as a LIFO queue with respect to idle resource instances always returning the most recently used resource from the pool, or as a FIFO queue, where borrow always returns the oldest instance from the idle resource list.fifodetermines whether or not the pool returns idle objects in first-in-first-out order. The default setting for this parameter isfalse.when_exhausted_action: (:fail | :block | :grow)specifies the behaviour of theborrowfunction when the pool is exhausted::failwill return an error.:blockwill block until a new or idle object is available. If a positivemax_waitvalue is supplied, thenborrowwill block for at most that many milliseconds, after which an error will be returned. Ifmax_waitis non-positive, theborrowfunction will block infinitely.:growwill create a new object and return it (essentially makingmax_activemeaningless.) The defaultwhen_exhausted_action:setting is:blockand the defaultmax_wait:setting is:infinity. By default, therefore,borrowwill block infinitely until an idle instance becomes available.
max_wait: (integer() | infinity)The maximum amount of time to wait when theborrowfunction is invoked, the pool is exhausted (the maximum number of "active" resource instances has been reached) andwhen_exhausted_action:equals:block.max_idle_time: (integer() | infinity)The maximum amount of time an resource instance may sit idle in the pool, with the extra condition that at leastmin_idleamount of object remain in the pool. When infinity, no instances will be evicted from the pool due to maximum idle time limit.
Specs
The function sends resource to the pool's idle container after client does not need it any more.