Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Trivially small thread pool implementation for Ruby
Ruby
Branch: master
Pull request Compare This branch is 18 commits ahead of benb:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
LICENCE
README.rdoc
Rakefile
VERSION
babypool.gemspec

README.rdoc

Baby Pool: Simple thread pool.

Baby Pool is a simple, but solid implementation of a thread pool using Ruby green threads. Pools are initialized with a thread count and an execution limit. Baby Pool creates an array or workers each in their own thread that listen for incoming jobs.

The pool will continue to accept work until it is drained by calling the drain method.

A quick example:

  • Initialize the pool with a thread count and an execution limit. Each thread's worker will timeout it's current job when it reaches the pool's execution limit.

pool = Babypool.new(:thread_count => 10, :execution_limit => 20)

  • Give the pool 20 jobs to do.

(0..20).each do |job| pool.work(job) do puts “Running job #{job}.” end end

  • When you are done, shut down the pool by calling the drain method

pool.drain

Something went wrong with that request. Please try again.