]> gitweb.factorcode.org Git - factor.git/commitdiff
concurrency.mailboxes: some cleanup and docs.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 15:51:43 +0000 (07:51 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 15:51:43 +0000 (07:51 -0800)
basis/concurrency/mailboxes/mailboxes-docs.factor
basis/concurrency/mailboxes/mailboxes.factor

index 85d393b0c286d75b44443d21f476e1070e3f0921..fea965b3f3584cf31900e6f2d8e69d73fe8587ac 100644 (file)
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax kernel arrays calendar ;
+USING: help.markup help.syntax kernel calendar sequences ;
 IN: concurrency.mailboxes
 
 HELP: <mailbox>
@@ -29,15 +29,19 @@ HELP: block-if-empty
 { $values { "mailbox" mailbox }
     { "timeout" { $maybe duration } }
 }
-{ $description "Block the thread if the mailbox is empty." } ;
+{ $description "Block the thread for " { $snippet "timeout" } " if the mailbox is empty." } ;
 
 HELP: mailbox-get
 { $values { "mailbox" mailbox } { "obj" object } }
 { $description "Get the first item put into the mailbox. If it is empty, the thread blocks until an item is put into it. The thread then resumes, leaving the item on the stack." } ;
 
+HELP: mailbox-get-all-timeout
+{ $values { "mailbox" mailbox } { "timeout" { $maybe duration } } { "seq" sequence } }
+{ $description "Blocks the thread for " { $snippet "timeout" } " if the mailbox is empty, then removes all objects in the mailbox and returns a sequence containing the objects." } ;
+
 HELP: mailbox-get-all
-{ $values { "mailbox" mailbox } { "array" array } }
-{ $description "Blocks the thread if the mailbox is empty, otherwise removes all objects in the mailbox and returns an array containing the objects." } ;
+{ $values { "mailbox" mailbox } { "seq" sequence } }
+{ $description "Blocks the thread if the mailbox is empty, then removes all objects in the mailbox and returns a sequence containing the objects." } ;
 
 HELP: while-mailbox-empty
 { $values { "mailbox" mailbox }
@@ -69,7 +73,10 @@ ARTICLE: "concurrency.mailboxes" "Mailboxes"
     mailbox-get-timeout?
 }
 "Emptying out a mailbox:"
-{ $subsections mailbox-get-all }
+{ $subsections
+    mailbox-get-all
+    mailbox-get-all-timeout
+}
 "Adding an element:"
 { $subsections mailbox-put }
 "Testing if a mailbox is empty:"
index ff0032c6c57cb9b05adf24bb2e7e5ed835572e77..bac28d058b3c0b1496c832f7de5ace493ebde629 100755 (executable)
@@ -47,10 +47,10 @@ M: mailbox mailbox-get-timeout block-if-empty data>> pop-back ;
 : mailbox-get ( mailbox -- obj )
     f mailbox-get-timeout ; inline
 
-: mailbox-get-all-timeout ( mailbox timeout -- array )
+: mailbox-get-all-timeout ( mailbox timeout -- seq )
     block-if-empty data>> [ ] collector [ slurp-deque ] dip ;
 
-: mailbox-get-all ( mailbox -- array )
+: mailbox-get-all ( mailbox -- seq )
     f mailbox-get-all-timeout ;
 
 : while-mailbox-empty ( mailbox quot -- )