Module: Circuitry::Processors::Threader

Extended by:
Circuitry::Processor
Defined in:
lib/circuitry/processors/threader.rb

Class Method Summary collapse

Methods included from Circuitry::Processor

flush, on_exit, process

Class Method Details

.flushObject



18
19
20
21
22
# File 'lib/circuitry/processors/threader.rb', line 18

def flush
  pool.each(&:join)
ensure
  pool.clear
end

.process(&block) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/circuitry/processors/threader.rb', line 9

def process(&block)
  raise ArgumentError, 'no block given' unless block_given?

  pool << Thread.new do
    safely_process(&block)
    on_exit.call if on_exit
  end
end