我正在尝试使用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)错误。有没有一种方法可以从这样的列表中弹出每一项,而不会出现堆栈溢出错误?
发布于 2012-06-14 08:11:03
问题是纤程只能处理4kb的堆栈。处理100个项目的列表将导致它堆叠在flow上。
看起来他们正在为光纤实现一个可重新调整大小的堆栈。http://bugs.ruby-lang.org/issues/3187
https://stackoverflow.com/questions/11024850
复制相似问题