From a27f560475301a0287e97d4ba2cbabb248cf2be7 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 23 Aug 2018 20:32:01 -0700 Subject: [PATCH] timers: fix issue with restart-timer after timer went off. --- basis/timers/timers-tests.factor | 9 +++++++++ basis/timers/timers.factor | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/basis/timers/timers-tests.factor b/basis/timers/timers-tests.factor index 35f8483dcf..5abb0023e0 100644 --- a/basis/timers/timers-tests.factor +++ b/basis/timers/timers-tests.factor @@ -64,3 +64,12 @@ threads tools.test tools.time ; 700 milliseconds sleep dup restart-timer 700 milliseconds sleep stop-timer 500 milliseconds sleep ] unit-test + +{ { 2 } } [ + { 0 } + dup '[ 0 _ [ 1 + ] change-nth ] 300 milliseconds f + dup restart-timer + 700 milliseconds sleep + dup restart-timer drop + 700 milliseconds sleep +] unit-test diff --git a/basis/timers/timers.factor b/basis/timers/timers.factor index cbe9870573..925fc246a7 100644 --- a/basis/timers/timers.factor +++ b/basis/timers/timers.factor @@ -94,11 +94,10 @@ PRIVATE> ] if ; : restart-timer ( timer -- ) - t >>restart? dup quotation-running?>> [ - drop + t >>restart? drop ] [ - dup thread>> [ nip interrupt ] [ start-timer ] if* + dup thread>> [ interrupt ] when* start-timer ] if ;