Project

threadpool

0.02
No commit activity in last 3 years
No release in over 3 years
A simple no-wasted-resources thread pool implementation.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ThreadPool - an implementation that doesn't waste CPU resources

GEM MERGED INTO THREAD, THIS IS UNMAINTAINED NOW: https://github.com/meh/ruby-thread

All the implementations I looked at were either buggy or wasted CPU resources for no apparent reason, for example used a sleep of 0.01 seconds to then check for readiness and stuff like this.

This implementation uses standard locking functions to work properly across multiple Ruby implementations.

Example

require 'threadpool'

pool = ThreadPool.new(4)

0.upto(10) { pool.process { sleep 2; puts 'lol' } }

gets # otherwise the program ends without the pool doing anything

You should get 4 lols every 2 seconds.