Class: GitMulticast::Task::Pool
- Inherits:
-
Object
- Object
- GitMulticast::Task::Pool
- Defined in:
- lib/git_multicast/task/pool.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(size) ⇒ Pool
constructor
A new instance of Pool.
- #schedule(*args, &blk) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(size) ⇒ Pool
Returns a new instance of Pool.
10 11 12 13 14 |
# File 'lib/git_multicast/task/pool.rb', line 10 def initialize(size) @size = size @queue = Queue.new @pool = (1..size).map { Thread.new(&job_loop) } end |
Class Method Details
.pool ⇒ Object
6 7 8 |
# File 'lib/git_multicast/task/pool.rb', line 6 def self.pool @pool ||= new(20) end |
Instance Method Details
#schedule(*args, &blk) ⇒ Object
16 17 18 |
# File 'lib/git_multicast/task/pool.rb', line 16 def schedule(*args, &blk) queue << [blk, args] end |
#shutdown ⇒ Object
20 21 22 23 |
# File 'lib/git_multicast/task/pool.rb', line 20 def shutdown size.times { schedule { throw :exit } } pool.map(&:join) end |