diff --git a/basis/concurrency/mailboxes/mailboxes-docs.factor b/basis/concurrency/mailboxes/mailboxes-docs.factor index 85d393b0c2..fea965b3f3 100644 --- a/basis/concurrency/mailboxes/mailboxes-docs.factor +++ b/basis/concurrency/mailboxes/mailboxes-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax kernel arrays calendar ; +USING: help.markup help.syntax kernel calendar sequences ; IN: concurrency.mailboxes HELP: @@ -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:" diff --git a/basis/concurrency/mailboxes/mailboxes.factor b/basis/concurrency/mailboxes/mailboxes.factor index ff0032c6c5..bac28d058b 100755 --- a/basis/concurrency/mailboxes/mailboxes.factor +++ b/basis/concurrency/mailboxes/mailboxes.factor @@ -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 -- )