Sha256: 0a7062d37c4c522371881b779c59e18f7cff97e1b7ed2c5a10291f5ea405ccd6

Contents?: true

Size: 420 Bytes

Versions: 5

Compression:

Stored size: 420 Bytes

Contents

module EventMachine
  module Synchrony

    class FiberIterator < EM::Synchrony::Iterator

      # execute each iterator block within its own fiber
      # and auto-advance the iterator after each call
      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

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
em-synchrony-1.0.4 lib/em-synchrony/fiber_iterator.rb
em-synchrony-1.0.3 lib/em-synchrony/fiber_iterator.rb
em-synchrony-1.0.2 lib/em-synchrony/fiber_iterator.rb
em-synchrony-1.0.1 lib/em-synchrony/fiber_iterator.rb
em-synchrony-1.0.0 lib/em-synchrony/fiber_iterator.rb