class EventMachine::Iterator
def initialize(list, concurrency = 1)
EventMachine::Iterator::Stop to signal the end of the iterations.
to be processed each time it is called. If a proc is used, it must return
The list may either be an array-like object, or a proc that returns a new object
is started via #each, #map or #inject
will create an iterator over the range that processes 10 items at a time. Iteration
i = EM::Iterator.new(1..100, 10)
Create a new parallel async iterator with specified concurrency.
def initialize(list, concurrency = 1) raise ArgumentError, 'concurrency must be bigger than zero' unless (concurrency > 0) if list.respond_to?(:call) @list = nil @list_proc = list elsif list.respond_to?(:to_a) @list = list.to_a.dup @list_proc = nil else raise ArgumentError, 'argument must be a proc or an array' end @concurrency = concurrency @started = false @ended = false end