This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Herryanto Siatono (author)
Fri Jan 23 20:09:59 -0800 2009
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | Fri Jan 23 19:59:59 -0800 2009 | |
| |
MIT-LICENSE | Fri Jan 23 19:59:59 -0800 2009 | |
| |
README | Fri Jan 23 20:09:59 -0800 2009 | |
| |
Rakefile | Fri Jan 23 19:59:59 -0800 2009 | |
| |
doc/ | Fri Jan 23 19:59:59 -0800 2009 | |
| |
lib/ | Fri Jan 23 19:59:59 -0800 2009 | |
| |
pkg/ | Fri Jan 23 19:59:59 -0800 2009 | |
| |
test/ | Fri Jan 23 19:59:59 -0800 2009 |
README
== common-pool
First in first out (FIFO) object pooling mechanism with idle objects eviction check, similar with {Apache Common
Pool}[link:http://jakarta.apache.org/commons/pool/].
It supports the following configuration parameters:
* min_idle
* max_idle
* max_idle_time
* max_active
* timeout
* validation_timeout
* idle_check_no_per_run
* idle_check_interval
Overwrite <code>CommonPool::PoolDataSource</code> to create object to be returned to the pool.
== Installation
$ gem install common-pool
== Example
require 'common_pool'
# Extend data source object
class RandomNumberDataSource < CommonPool::PoolDataSource
# Overwrite to return object to be stored in the pool.
def create_object
rand(1000)
end
# Overwrite to check if idle object in the pool is still valid.
def valid?(object)
true
end
end
# Create a new object pool
object_pool = ObjectPool.new(RandomNumberDataSource.new)
# Borrow object from the pool
object = object_pool.borrow_object
# Return object to the pool
object_pool.return_object(object)
# Or invalidate object and remove it from the pool
object_pool.invalidate_object(object)
# Create object pool with idle objects eviction thread
object_pool = ObjectPool.new(RandomNumberDataSource.new) do |config|
config.min_idle = 5
config.max_idle = 10
# max 10 idle objects checked per run
config.idle_check_no_per_run = 10
# check idle objects every 10 minutes
config.idle_check_interval = 10 * 60
end
# Return a hash of pool instance status variables, i.e.
# active and idle lists size, and configuration options
object_pool.status_info
== Source Codes
http://github.com/jugend/common-pool/tree/master
== Links
* http://www.pluitsolutions.com/common-pool







