Module: SlowEnumeratorTools::Util

Defined in:
lib/slow_enumerator_tools/util.rb

Constant Summary collapse

STOP_OK =
Object.new
STOP_ERR =
Object.new

Class Method Summary collapse

Class Method Details

.gen_collector_thread(enum, queue) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/slow_enumerator_tools/util.rb', line 8

def self.gen_collector_thread(enum, queue)
  Thread.new do
    begin
      enum.each { |e| queue << e }
      queue << STOP_OK
    rescue StandardError => e
      queue << STOP_ERR
      queue << e
    end
  end
end