]> gitweb.factorcode.org Git - factor.git/commitdiff
update docs for new alarms changes
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 24 Nov 2009 01:49:47 +0000 (19:49 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 24 Nov 2009 01:49:47 +0000 (19:49 -0600)
basis/alarms/alarms-docs.factor

index 2c5a567d62a94cf14fb9694d2a732d3547267a8e..396011a3515e26d791e29a7a8153ea6cf7924d47 100644 (file)
@@ -4,9 +4,23 @@ IN: alarms
 HELP: alarm\r
 { $class-description "An alarm. Can be passed to " { $link cancel-alarm } "." } ;\r
 \r
+HELP: current-alarm\r
+{ $description "A symbol that contains the currently executing alarm, availble only to the alarm quotation. One use for this symbol is if a repeated alarm wishes to cancel itself from executing in the future."\r
+}\r
+{ $examples\r
+    { $unchecked-example\r
+        """USING: alarms calendar io threads ;"""\r
+        """["""\r
+        """    "Hi, this should only get printed once..." print flush"""\r
+        """    current-alarm get cancel-alarm"""\r
+        """] 1 seconds every"""\r
+        ""\r
+    }\r
+} ;\r
+\r
 HELP: add-alarm\r
 { $values { "quot" quotation } { "start" duration } { "interval" { $maybe "duration/f" } } { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm to start at " { $snippet "start" } " offset from the current time. If " { $snippet "interval" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency, with scheduling happening before the quotation is called in order to ensure that the next event will happen on time. The quotation will be called from the alarm thread." } ;\r
+{ $description "Creates and registers an alarm to start at " { $snippet "start" } " offset from the current time. If " { $snippet "interval" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency, with scheduling happening before the quotation is called in order to ensure that the next event will happen on time. The quotation will be called from a new thread spawned by the alarm thread. If a repeated alarm's quotation throws an exception, the alarm will not be rescheduled." } ;\r
 \r
 HELP: later\r
 { $values { "quot" quotation } { "duration" duration } { "alarm" alarm } }\r
@@ -27,7 +41,7 @@ HELP: every
 { $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
+{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency. If the quotation throws an exception that is not caught inside it, the alarm scheduler will cancel the alarm and will not reschedule it again." }\r
 { $examples\r
     { $unchecked-example\r
         "USING: alarms io calendar ;"\r
@@ -44,6 +58,8 @@ ARTICLE: "alarms" "Alarms"
 { $subsections every }\r
 "Register a one-time alarm:"\r
 { $subsections later }\r
+"The currently executing alarm:"\r
+{ $subsections current-alarm }\r
 "Low-level interface to add alarms:"\r
 { $subsections add-alarm }\r
 "Cancelling an alarm:"\r