2012-06-13 40 views
0

我试图让此代码使用em-synchrony1.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错误?

回答

0

问题是光纤只能处理4kb的堆栈。 处理一个100个项目的清单将导致它堆栈溢出

看起来它们是关于它为光纤实现一个可调整大小的堆栈。 http://bugs.ruby-lang.org/issues/3187