1
require 'celluloid/current'
Celluloid.shutdown_timeout = 1
class Mapper
include Celluloid
attr_accessor :value
def run(num)
@value = num.times.map { |idx| idx }
end
end
y = Mapper.spawn
y.future.run(1000000)
到目前为止,似乎工作和演员都在1秒后关机终止与Celluloid.shutdown_timeout所有演员。赛璐珞演员 - 如何在使用期货
y.value
但是,当我尝试访问像上面那样的值时,它一直持续到方法调用返回的值可用。
我的想法是使用Celluloid.shutdown_timeout就像标准Timeout.timeout(1){}
,如果超过1秒的时间限制[终止块Timeout.timeout(1)是臭名昭着,因此不使用它]
什么是正确的方式来实现这个使用赛璐珞演员?