Class: Pool
- Inherits:
-
Object
- Object
- Pool
- Defined in:
- lib/pool.rb
Instance Method Summary collapse
- #<<(block) ⇒ Object
-
#initialize(options) ⇒ Pool
constructor
A new instance of Pool.
Constructor Details
#initialize(options) ⇒ Pool
Returns a new instance of Pool.
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pool.rb', line 2 def initialize() @min_threads = [:threads] @queue = Queue.new @threads = [] @min_threads.times do |i| @threads << Thread.new { while true block = @queue.pop block.call end } end end |
Instance Method Details
#<<(block) ⇒ Object
16 17 18 |
# File 'lib/pool.rb', line 16 def <<(block) @queue << block end |