 
 : restart-timer ( timer -- )
     dup thread>> [
-        t >>next-nanos [ thread>> ] [ ?interrupt ] bi
+        dup delay-nanos >>next-nanos
+        [ thread>> ] [ ?interrupt ] bi
     ] [
         start-timer
     ] if ;


: start-timer ( timer -- )
    dup thread>> [ timer-already-started ] when
    t >>next-nanos
    dup '[ _ timer-loop ] "Timer" <thread>
    [ >>thread drop ] [ (spawn) ] bi ;


    [ dupd [ mod ] [ swap - ] bi + + ] [ 2drop f ] if* ;

: next-nanos ( timer -- timer n/f )
    dup thread>> self eq? [ dup next-nanos>> ] [ f ] if ;

: run-timer ( timer -- timer )
    dup interval-nanos >>next-nanos
