Class: EventMachine::Synchrony::FiberIterator

Inherits:
EM::Synchrony::Iterator
  • Object
show all
Defined in:
lib/em-synchrony/fiber_iterator.rb

Instance Method Summary collapse

Instance Method Details

#each(foreach = nil, after = nil, &blk) ⇒ Object

execute each iterator block within its own fiber and auto-advance the iterator after each call


8
9
10
11
12
13
14
# File 'lib/em-synchrony/fiber_iterator.rb', line 8

def each(foreach=nil, after=nil, &blk)
  fe = Proc.new do |obj, iter|
    Fiber.new { (foreach || blk).call(obj); iter.next }.resume
  end

  super(fe, after)
end