timers: fix issue with restart-timer after timer went off.

handle-patch-and-put
John Benediktsson 2018-08-23 20:32:01 -07:00
parent 91e55dc02a
commit a27f560475
2 changed files with 11 additions and 3 deletions

View 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

View 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