 
 PRIVATE>
 
-: alarm-overdue ( alarm -- n/f )
-    dup { [ interval>> not ] [ previous-iteration-begin>> 0 = ] } 1|| [
-        drop f
-    ] [
-        [ iteration-begin>> ]
-        [ previous-iteration-begin>> - ]
-        [ interval>> ] tri 2dup >= [
-            nip
-        ] [
-            2drop f
-        ] if
-    ] if ;
-
 : add-alarm ( quot start interval -- alarm )
     <alarm> [ register-alarm ] keep ;
 

    { quot callable initial: [ ] }
    { start integer }
    interval
    { previous-iteration-begin integer }
    { iteration-begin integer }
    { stop? boolean } ;

SYMBOL: alarms

: <alarm> ( quot start interval -- alarm )
    alarm new
        swap >nanoseconds >>interval
        swap >nanoseconds nano-count +
            [ >>start ] [ >>iteration-scheduled ] bi
        swap >>quot ; inline

: register-alarm ( alarm -- )
    dup start>> alarms get-global heap-push* drop
