Ruby 块内周期计时器中的EventMachine更改延迟
调用周期计时器,当块内发生错误时,更改周期计时器延迟。我可以使用周期计时器还是最好的方法是添加计时器 嗨,我想这样做:Ruby 块内周期计时器中的EventMachine更改延迟,ruby,timer,eventmachine,Ruby,Timer,Eventmachine,调用周期计时器,当块内发生错误时,更改周期计时器延迟。我可以使用周期计时器还是最好的方法是添加计时器 嗨,我想这样做: EventMachine.run EventMachine.add_periodic_timer 1 //read from a input //if error set timer to 20s //if ok set timer to 1s end end 怎么做? 感谢您自己创建PeriodicTimer对象,并调用其访问
EventMachine.run
EventMachine.add_periodic_timer 1
//read from a input
//if error set timer to 20s
//if ok set timer to 1s
end
end
怎么做?
感谢您自己创建
PeriodicTimer
对象,并调用其访问器interval=
设置间隔:
EventMachine.run do
timer = EventMachine::PeriodicTimer.new(1) do
puts "Timer fired at #{Time.now}"
end
# timer.interval = 1
# timer.interval = 20
end
是的,我几分钟前就找到了!谢谢