Skip to content

counterleft/claws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claws

Build Status Code Climate

A thread pool library extracted from puma.

This gem is alpha. It is not ready for public consumption yet.

Installation

Add this line to your application's Gemfile:

gem 'claws'

And then execute:

$ bundle

Or install it yourself as:

$ gem install claws

Usage

Full Example

# 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

Contributing

  1. Fork it ( http://github.com/winterchord/claws/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

A ruby thread pool library extracted from puma.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages