/usr/lib/ruby/vendor_ruby/em-synchrony/iterator.rb is in ruby-em-synchrony 1.0.5-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | require "em/iterator"
module EventMachine
module Synchrony
class Iterator < EM::Iterator
# synchronous iterator which will wait until all the
# jobs are done before returning. Unfortunately this
# means that you loose ability to choose concurrency
# on the fly (see iterator documentation in EM)
def each(foreach=nil, after=nil, &blk)
fiber = Fiber.current
fe = (foreach || blk)
cb = Proc.new do
after.call if after
fiber.resume
end
Fiber.yield super(fe, cb)
end
def map(&block)
fiber = Fiber.current
result = nil
after = Proc.new {|res| result = res; fiber.resume }
super(block, after)
Fiber.yield
result
end
def inject(obj, foreach = nil, after = nil, &block)
if foreach and after
super(obj, foreach, after)
else
fiber = Fiber.current
result = nil
after = Proc.new {|res| result = res; fiber.resume}
super(obj, block, after)
Fiber.yield
result
end
end
end
end
end
|