 
 : start-timer ( timer -- )
     dup thread>> [ timer-already-started ] when
-    t >>next-nanos
+    dup delay-nanos >>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>> dup t eq? [
            drop dup delay-nanos [ >>next-nanos ] keep
        ] when
    ] [ f ] if ;

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


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