]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/concurrency/mailboxes/mailboxes-docs.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / basis / concurrency / mailboxes / mailboxes-docs.factor
index 0cd23dc1b559a6a2ae2a961c759dcec7b5a41cb3..5c15bc85f281edbed54caa89252b13be37ef29b9 100644 (file)
@@ -1,81 +1,81 @@
-USING: help.markup help.syntax kernel arrays calendar ;\r
-IN: concurrency.mailboxes\r
-\r
-HELP: <mailbox>\r
-{ $values { "mailbox" mailbox } }\r
-{ $description "A mailbox is an object that can be used for safe thread communication. Items can be put in the mailbox and retrieved in a FIFO order. If the mailbox is empty when a get operation is performed then the thread will block until another thread places something in the mailbox. If multiple threads are waiting on the same mailbox, only one of the waiting threads will be unblocked to thread the get operation." } ;\r
-\r
-HELP: mailbox-empty?\r
-{ $values { "mailbox" mailbox }\r
-          { "bool" boolean }\r
-}\r
-{ $description "Return true if the mailbox is empty." } ;\r
-\r
-HELP: mailbox-put\r
-{ $values { "obj" object }\r
-          { "mailbox" mailbox }\r
-}\r
-{ $description "Put the object into the mailbox. Any threads that have a blocking get on the mailbox are resumed. Only one of those threads will successfully get the object, the rest will immediately block waiting for the next item in the mailbox." } ;\r
-\r
-HELP: block-unless-pred\r
-{ $values\r
-    { "mailbox" mailbox }\r
-    { "timeout" { $maybe duration } }\r
-    { "pred" { $quotation ( ... message -- ... ? ) } }\r
-}\r
-{ $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack." } ;\r
-\r
-HELP: block-if-empty\r
-{ $values { "mailbox" mailbox }\r
-    { "timeout" { $maybe duration } }\r
-}\r
-{ $description "Block the thread if the mailbox is empty." } ;\r
-\r
-HELP: mailbox-get\r
-{ $values { "mailbox" mailbox } { "obj" object } }\r
-{ $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." } ;\r
-\r
-HELP: mailbox-get-all\r
-{ $values { "mailbox" mailbox } { "array" array } }\r
-{ $description "Blocks the thread if the mailbox is empty, otherwise removes all objects in the mailbox and returns an array containing the objects." } ;\r
-\r
-HELP: while-mailbox-empty\r
-{ $values { "mailbox" mailbox }\r
-          { "quot" { $quotation ( -- ) } }\r
-}\r
-{ $description "Repeatedly call the quotation while there are no items in the mailbox." } ;\r
-\r
-HELP: mailbox-get?\r
-{ $values { "mailbox" mailbox }\r
-          { "pred" { $quotation ( obj -- ? ) } }\r
-          { "obj" object }\r
-}\r
-{ $description "Get the first item in the mailbox which satisfies the predicate. When the predicate returns true that item will be returned. If nothing in the mailbox satisfies the predicate then the thread will block until something does." } ;\r
-\r
-ARTICLE: "concurrency.mailboxes" "Mailboxes"\r
-"A " { $emphasis "mailbox" } " is a first-in-first-out queue where the operation of removing an element blocks if the queue is empty. Mailboxes are implemented in the " { $vocab-link "concurrency.mailboxes" } " vocabulary."\r
-{ $subsections\r
-    mailbox\r
-    <mailbox>\r
-}\r
-"Removing the first element:"\r
-{ $subsections\r
-    mailbox-get\r
-    mailbox-get-timeout\r
-}\r
-"Removing the first element matching a predicate:"\r
-{ $subsections\r
-    mailbox-get?\r
-    mailbox-get-timeout?\r
-}\r
-"Emptying out a mailbox:"\r
-{ $subsections mailbox-get-all }\r
-"Adding an element:"\r
-{ $subsections mailbox-put }\r
-"Testing if a mailbox is empty:"\r
-{ $subsections\r
-    mailbox-empty?\r
-    while-mailbox-empty\r
-} ;\r
-\r
-ABOUT: "concurrency.mailboxes"\r
+USING: help.markup help.syntax kernel arrays calendar ;
+IN: concurrency.mailboxes
+
+HELP: <mailbox>
+{ $values { "mailbox" mailbox } }
+{ $description "A mailbox is an object that can be used for safe thread communication. Items can be put in the mailbox and retrieved in a FIFO order. If the mailbox is empty when a get operation is performed then the thread will block until another thread places something in the mailbox. If multiple threads are waiting on the same mailbox, only one of the waiting threads will be unblocked to thread the get operation." } ;
+
+HELP: mailbox-empty?
+{ $values { "mailbox" mailbox }
+          { "bool" boolean }
+}
+{ $description "Return true if the mailbox is empty." } ;
+
+HELP: mailbox-put
+{ $values { "obj" object }
+          { "mailbox" mailbox }
+}
+{ $description "Put the object into the mailbox. Any threads that have a blocking get on the mailbox are resumed. Only one of those threads will successfully get the object, the rest will immediately block waiting for the next item in the mailbox." } ;
+
+HELP: block-unless-pred
+{ $values
+    { "mailbox" mailbox }
+    { "timeout" { $maybe duration } }
+    { "pred" { $quotation ( ... message -- ... ? ) } }
+}
+{ $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack." } ;
+
+HELP: block-if-empty
+{ $values { "mailbox" mailbox }
+    { "timeout" { $maybe duration } }
+}
+{ $description "Block the thread 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
+{ $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." } ;
+
+HELP: while-mailbox-empty
+{ $values { "mailbox" mailbox }
+          { "quot" { $quotation ( -- ) } }
+}
+{ $description "Repeatedly call the quotation while there are no items in the mailbox." } ;
+
+HELP: mailbox-get?
+{ $values { "mailbox" mailbox }
+          { "pred" { $quotation ( obj -- ? ) } }
+          { "obj" object }
+}
+{ $description "Get the first item in the mailbox which satisfies the predicate. When the predicate returns true that item will be returned. If nothing in the mailbox satisfies the predicate then the thread will block until something does." } ;
+
+ARTICLE: "concurrency.mailboxes" "Mailboxes"
+"A " { $emphasis "mailbox" } " is a first-in-first-out queue where the operation of removing an element blocks if the queue is empty. Mailboxes are implemented in the " { $vocab-link "concurrency.mailboxes" } " vocabulary."
+{ $subsections
+    mailbox
+    <mailbox>
+}
+"Removing the first element:"
+{ $subsections
+    mailbox-get
+    mailbox-get-timeout
+}
+"Removing the first element matching a predicate:"
+{ $subsections
+    mailbox-get?
+    mailbox-get-timeout?
+}
+"Emptying out a mailbox:"
+{ $subsections mailbox-get-all }
+"Adding an element:"
+{ $subsections mailbox-put }
+"Testing if a mailbox is empty:"
+{ $subsections
+    mailbox-empty?
+    while-mailbox-empty
+} ;
+
+ABOUT: "concurrency.mailboxes"