]> gitweb.factorcode.org Git - factor.git/blob - basis/concurrency/combinators/combinators-docs.factor
28d6d11bd58cf37f75606b38979dcebbaba6b244
[factor.git] / basis / concurrency / combinators / combinators-docs.factor
1 USING: help.markup help.syntax sequences ;\r
2 IN: concurrency.combinators\r
3 \r
4 HELP: parallel-map\r
5 { $values { "seq" sequence } { "quot" { $quotation ( elt -- newelt ) } } { "newseq" sequence } }\r
6 { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the results at the end." }\r
7 { $errors "Throws an error if one of the iterations throws an error." } ;\r
8 \r
9 HELP: 2parallel-map\r
10 { $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( elt1 elt2 -- newelt ) } } { "newseq" sequence } }\r
11 { $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", collecting the results at the end." }\r
12 { $errors "Throws an error if one of the iterations throws an error." } ;\r
13 \r
14 HELP: parallel-each\r
15 { $values { "seq" sequence } { "quot" { $quotation ( elt -- ) } } }\r
16 { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", blocking until all quotations complete." }\r
17 { $errors "Throws an error if one of the iterations throws an error." } ;\r
18 \r
19 HELP: 2parallel-each\r
20 { $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( elt1 elt2 -- ) } } }\r
21 { $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", blocking until all quotations complete." }\r
22 { $errors "Throws an error if one of the iterations throws an error." } ;\r
23 \r
24 HELP: parallel-filter\r
25 { $values { "seq" sequence } { "quot" { $quotation ( elt -- ? ) } } { "newseq" sequence } }\r
26 { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the elements for which the quotation yielded a true value." }\r
27 { $errors "Throws an error if one of the iterations throws an error." } ;\r
28 \r
29 ARTICLE: "concurrency.combinators" "Concurrent combinators"\r
30 "The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of various combinators."\r
31 $nl\r
32 "Concurrent sequence combinators:"\r
33 { $subsections\r
34     parallel-each\r
35     2parallel-each\r
36     parallel-map\r
37     2parallel-map\r
38     parallel-filter\r
39 }\r
40 "Concurrent product sequence combinators:"\r
41 { $subsections\r
42     parallel-product-each\r
43     parallel-cartesian-each\r
44     parallel-product-map\r
45     parallel-cartesian-map\r
46 }\r
47 "Concurrent cleave combinators:"\r
48 { $subsections\r
49     parallel-cleave\r
50     parallel-spread\r
51     parallel-napply\r
52 }\r
53 "The " { $vocab-link "concurrency.semaphores" } " vocabulary can be used in conjunction with the above combinators to limit the maximum number of concurrent operations." ;\r
54 \r
55 ABOUT: "concurrency.combinators"\r