singleton method Plato::Timer.delete_timer
delete_timer(id) -> nil
指定したタイマIDのタイマ処理を停止・削除します。
引数 |
|
id |
削除対象のタイマ処理のIDを指定します。(タイマIDはadd_timerの戻り値として返されます) |
例:
prc = Proc.new {|arg| puts arg}
lmd = lambda {|arg| puts arg * 2}
tid1 = Plato::Timer.add_timer(1000, prc, "Proc") # Procを1秒周期起動で登録します
tid2 = Plato::Timer.add_timer(2000, lmd, "lambda") # lambdaを2秒周期起動で登録します
et = Plato::Machine.millis + 10000
Plato::Timer.start
loop {
if et < Plato::Machine.millis # 10秒経過したら
Plato::Timer.delete_timer(tid1) # Procの周期起動を停止します
end
Plato::Timer.refresh
Plato::Machine.delay(1)
}