 <PRIVATE
 
 : (start-timer) ( quot start-duration interval-duration -- timer )
-    <timer> [ start-timer ] keep ;
+    <timer> [ start-timer ] keep ; inline
 
 PRIVATE>
 

        delay-nanos>> [ sleep ] when*
    ] if ;

: timer-loop ( timer -- )
    [ sleep-delay ]
    [ nano-count >>iteration-start-nanos call-timer-loop ]
    [ dup restart?>> [ f >>restart? timer-loop ] [ drop ] if ] tri ;

M: real >nanoseconds >integer ;
M: duration >nanoseconds duration>nanoseconds >integer ;

TYPED: set-next-timer-time ( timer: timer -- timer )
    ! start + delay + ceiling((now - (start + delay)) / interval) * interval
    nano-count
    over start-nanos>> -
    over delay-nanos>> [ - ] when*
    over interval-nanos>> / ceiling
