Method: ThreadPool#in_groups

Defined in:
lib/nswtopo/helpers/thread_pool.rb

#in_groups(&block) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/nswtopo/helpers/thread_pool.rb', line 30

def in_groups(&block)
  queue = Queue.new
  threads(queue, &block).tap do
    @args.group_by.with_index do |args, index|
      index % @size
    end.values.inject(queue, &:<<).close
  end.each(&:join)
  @args
end