0
我試圖讓此代碼使用em-synchrony
1.0.1
。遞歸隊列導致「堆棧級別太深」
require "em-synchrony"
class Worker
attr_reader :station_queue, :list
def initialize
@station_queue = EM::Queue.new
@list = ["value"] * 100
end
def run!
station_queue.push(*list)
station_popper = proc do |station|
# Do some work with #{station}
station_queue.pop(station_popper)
end
station_queue.pop(station_popper)
end
end
EM::synchrony { Worker.new.run! }
問題是我得到ruby-1.9.2-p290/gems/em-synchrony-1.0.1/lib/em-synchrony.rb:26: stack level too deep (SystemStackError)
錯誤。有沒有辦法從這樣的列表中彈出每個項目而不會出現stackoverflow錯誤?