2008-02-21 21:57:41 -05:00
USING: help.markup help.syntax calendar quotations ;
2009-11-15 00:28:18 -05:00
IN: alarms
2008-02-21 20:19:21 -05:00
HELP: alarm
2008-05-21 22:31:54 -04:00
{ $class-description "An alarm. Can be passed to " { $link cancel-alarm } "." } ;
2008-02-21 20:19:21 -05:00
HELP: add-alarm
2008-11-16 07:02:13 -05:00
{ $values { "quot" quotation } { "time" timestamp } { "frequency" { $maybe duration } } { "alarm" alarm } }
2009-11-15 00:28:18 -05:00
{ $description "Creates and registers an alarm to start at " { $snippet "time" } ". 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." } ;
2008-02-21 20:19:21 -05:00
2008-02-22 00:47:06 -05:00
HELP: later
2008-09-04 19:14:24 -04:00
{ $values { "quot" quotation } { "duration" duration } { "alarm" alarm } }
2009-11-15 00:28:18 -05:00
{ $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } " from now." }
{ $examples
{ $unchecked-example
"USING: alarms io calendar ;"
"" "[ " GET BACK TO WORK, Guy." print flush ] 10 minutes later drop" ""
""
}
} ;
2008-02-22 00:47:06 -05:00
2008-02-21 20:19:21 -05:00
HELP: cancel-alarm
{ $values { "alarm" alarm } }
2008-02-23 23:29:46 -05:00
{ $description "Cancels an alarm. Does nothing if the alarm is not active." } ;
2008-02-21 20:19:21 -05:00
2008-09-04 19:14:24 -04:00
HELP: every
{ $values
{ "quot" quotation } { "duration" duration }
{ "alarm" alarm } }
2009-11-15 00:28:18 -05:00
{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency." }
{ $examples
{ $unchecked-example
"USING: alarms io calendar ;"
"" "[ " Hi Buddy." print flush ] 10 seconds every drop" ""
""
}
} ;
2008-09-04 19:14:24 -04:00
2008-02-21 20:19:21 -05:00
ARTICLE: "alarms" "Alarms"
2009-11-15 00:28:18 -05:00
"The " { $vocab-link "alarms" } " vocabulary provides a lightweight way to schedule one-time and recurring tasks without spawning a new thread." $nl
"The alarm class:"
2009-10-01 15:56:36 -04:00
{ $subsections
alarm
}
2009-11-15 00:28:18 -05:00
"Register a recurring alarm:"
{ $subsections every }
"Register a one-time alarm:"
{ $subsections later }
"Low-level interface to add alarms:"
{ $subsections add-alarm }
"Cancelling an alarm:"
{ $subsections cancel-alarm }
2008-02-22 17:18:45 -05:00
"Alarms do not persist across image saves. Saving and restoring an image has the effect of calling " { $link cancel-alarm } " on all " { $link alarm } " instances." ;
2008-02-21 20:19:21 -05:00
ABOUT: "alarms"