Concurrent enumeration

Hello all,

I am wondering if it is possible to concurrently run the below
Enumerations in separate Threads? Input should be considered larger than
memory.

Cheers,

Martin

def fib(n) n < 2 ? n : fib(n-1)+fib(n-2); end # Lousy Fibonacci
calculator <- heavy job

cmd1 = lambda do |input, output|
puts “cmd1 lamda called”
fib(30)
input.each { |e| output << (e + 1) }
end

cmd2 = lambda do |input, output|
puts “cmd2 lamda called”
fib(30)
input.each { |e| output << (e + 1) }
end

cmd3 = lambda do |input, output|
puts “cmd3 lamda called”
fib(30)
input.each { |e| output << (e + 1) }
end

input = (0 … 10).to_enum

enum1 = Enumerator.new do |output|
cmd1.call(input, output)
end

enum2 = Enumerator.new do |output|
cmd2.call(enum1, output)
end

enum3 = Enumerator.new do |output|
cmd3.call(enum2, output)
end

enum3.each { |e| p e }