A thread pool library extracted from puma.
This gem is alpha. It is not ready for public consumption yet.
Add this line to your application's Gemfile:
gem 'claws'
And then execute:
$ bundle
Or install it yourself as:
$ gem install claws
# the minimum number of threads that should be in the pool at a given time
min = 1
# the maximum number of threads that should be in the pool at a given time
max = 2
contents = []
# work is what will be performed by each thread
pool = Claws::ThreadPool.new(min, max) do |work|
contents << work
end
# add "work" to the pool
pool << "foo"
pool << 1
# contents => [1, "foo"]
pool.spawned # => 1
# Tell all threads in the pool to exit (pool waits for them to finish)
pool.shutdown # => []
pool.spawned # => 0
- Fork it ( http://github.com/winterchord/claws/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request