]> gitweb.factorcode.org Git - factor.git/commitdiff
timers: fix issue with restart-timer after timer went off.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 24 Aug 2018 03:32:01 +0000 (20:32 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 24 Aug 2018 03:32:01 +0000 (20:32 -0700)
basis/timers/timers-tests.factor
basis/timers/timers.factor

index 35f8483dcf1a4c6d27b7df9408eb04d8cf516a47..5abb0023e0fc335304e0472a9f8fb4bda56cac37 100644 (file)
@@ -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 <timer>
+    dup restart-timer
+    700 milliseconds sleep
+    dup restart-timer drop
+    700 milliseconds sleep
+] unit-test
index cbe98705736d254e8184b5c469b2b494f3cb72eb..925fc246a7b01fba39b4c90ec2fd75cb04aee720 100644 (file)
@@ -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 ;
 
 <PRIVATE