]> gitweb.factorcode.org Git - factor.git/blob - basis/concurrency/exchangers/exchangers-docs.factor
factor: trim using lists
[factor.git] / basis / concurrency / exchangers / exchangers-docs.factor
1 USING: help.markup help.syntax kernel ;
2 IN: concurrency.exchangers
3
4 HELP: exchanger
5 { $class-description "The class of object exchange points." } ;
6
7 HELP: <exchanger>
8 { $values { "exchanger" exchanger } }
9 { $description "Creates a new object exchange point." } ;
10
11 HELP: exchange
12 { $values { "obj" object } { "exchanger" exchanger } { "newobj" object } }
13 { $description "Waits for another thread to call " { $link exchange } " on the same exchanger. The thread's call to " { $link exchange } " returns with " { $snippet "obj" } " on the stack, and the object passed to " { $link exchange } " by the other thread is left on the current's thread stack as " { $snippet "newobj" } "." } ;
14
15 ARTICLE: "concurrency.exchangers" "Object exchange points"
16 "The " { $vocab-link "concurrency.exchangers" } " vocabulary implements " { $emphasis "object exchange points" } ", which are rendezvous points where two threads can exchange objects."
17 { $subsections
18     exchanger
19     <exchanger>
20     exchange
21 }
22 "One use-case is two threads, where one thread reads data into a buffer and another thread processes the data. The reader thread can begin by reading the data, then passing the buffer through an exchanger, then recursing. The processing thread can begin by creating an empty buffer, and exchanging it through the exchanger. It then processes the result and recurses."
23 $nl
24 "The vocabulary was modelled after a similar feature in Java's " { $snippet "java.util.concurrent" } " library." ;
25
26 ABOUT: "concurrency.exchangers"