Erlang Resource Pool.

Copyright © 2013-2016 Alexei Krasnopolski

Version: 1.0.3

Introduced in: 2013-03-25

Authors: Alexei Krasnopolski (krasnop@bellsouth.net) [web site: http://krasnopolski.org].

References

Introduction

Resource pool project was inspired by Apache Commons Pool library and API was borrowed from there. But internal implementation is completely different and is using Erlang OTP design principles and Erlang concurrent model. Resource Pool is Erlang application library.

Structure

Getting started

  1. Create instance of Resource Pool
    {ok, Pid} = resource_pool:new(test_pool, resource_factory, [])
    where: New resource pool is usually shared between few processes.
  2. Borrow resource from pool
    Resource = resource_pool:borrow(test_pool)
    The process can use the borrowed resource and has to return to pool after finish.
  3. Return resource to pool
    ok = resource_pool:return(test_pool, Resource)
    The process can not use the Resource anymore.
  4. Pool can be created with options:
    Options = [{max_active, 10}, {when_exhausted_action, fail}]
    {ok, Pid} = resource_pool:new(test_pool, resource_factory, Options)
    See resource_pool for more details about options.

Generated by EDoc, Feb 14 2016, 02:21:40.