Navigation Menu

Skip to content

eguitarz/threadpool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Threadpool

Threadpool is the "threadpool pattern" implemented in ruby. It's a compact but robust component.

Features

  • Timeout jobs, it means the stuck threads will be recycled.
  • Job based tasks, job is an object not a block, could be more flexible.
  • MRI and JRuby are supported.

Install

Edit Gemfile

...
gem 'e-threadpool'
...

or

gem install e-threadpool

Example

require 'threadpool'

class TestJob < Job
  def run
    puts "hello"
  end
end

threadpool = Threadpool.new
100.times.each do
  # threadpool auto-executes the job after loaded
  threadpool.load(TestJob.new)
  # Sleep 10ms, prevent ouput too fast on console.
  sleep(0.01)
end

# shutdown will wait until all jobs are finished
threadpool.shutdown

License

MIT LICENSE, please refer to the LICENSE file.

About

Ruby based thread pool, able to avoid the zombie threads eat up the pool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages