{ $description "Creates and registers an alarm. If " { $snippet "frequency" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency. The quotation will be called from the alarm thread." } ;\r
\r
HELP: later\r
-{ $values { "quot" quotation } { "dt" duration } { "alarm" alarm } }\r
+{ $values { "quot" quotation } { "duration" duration } { "alarm" alarm } }\r
{ $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } " from now." } ;\r
\r
HELP: cancel-alarm\r
{ $values { "alarm" alarm } }\r
{ $description "Cancels an alarm. Does nothing if the alarm is not active." } ;\r
\r
+HELP: every\r
+{ $values\r
+ { "quot" quotation } { "duration" duration }\r
+ { "alarm" alarm } }\r
+{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency." } ;\r
+\r
ARTICLE: "alarms" "Alarms"\r
"Alarms provide a lightweight way to schedule one-time and recurring tasks without spawning a new thread."\r
{ $subsection alarm }\r
: add-alarm ( quot time frequency -- alarm )
<alarm> [ register-alarm ] keep ;
-: later ( quot dt -- alarm )
+: later ( quot duration -- alarm )
hence f add-alarm ;
-: every ( quot dt -- alarm )
+: every ( quot duration -- alarm )
[ hence ] keep add-alarm ;
: cancel-alarm ( alarm -- )