]> gitweb.factorcode.org Git - factor.git/blob - basis/concurrency/promises/promises-docs.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / basis / concurrency / promises / promises-docs.factor
1 ! Copyright (C) 2005, 2008 Chris Double, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: calendar help.markup help.syntax kernel ;
4 IN: concurrency.promises
5
6 HELP: promise
7 { $class-description "The class of write-once promises." } ;
8
9 HELP: <promise>
10 { $values { "promise" promise } }
11 { $description "Creates a new promise which may be fulfilled by calling " { $link fulfill } "." } ;
12
13 HELP: promise-fulfilled?
14 { $values { "promise" promise } { "?" boolean } }
15 { $description "Tests if " { $link fulfill } " has previously been called on the promise, in which case " { $link ?promise } " will return immediately without blocking." } ;
16
17 HELP: ?promise-timeout
18 { $values { "promise" promise } { "timeout" { $maybe duration } } { "result" object } }
19 { $description "Waits for another thread to fulfill a promise, returning immediately if the promise has already been fulfilled. A timeout of " { $link f } " indicates that the thread may block indefinitely, otherwise it will wait up to the " { $snippet "timeout" } " before throwing an error." }
20 { $errors "Throws an error if the timeout expires before the promise has been fulfilled." } ;
21
22 HELP: ?promise
23 { $values { "promise" promise } { "result" object } }
24 { $description "Waits for another thread to fulfill a promise, returning immediately if the promise has already been fulfilled." } ;
25
26 HELP: fulfill
27 { $values { "value" object } { "promise" promise } }
28 { $description "Fulfills a promise by writing a value to it. Any threads waiting for the value are notified." }
29 { $errors "Throws an error if the promise has already been fulfilled." } ;
30
31 ARTICLE: "concurrency.promises" "Promises"
32 "The " { $vocab-link "concurrency.promises" } " vocabulary implements " { $emphasis "promises" } ", which are thread-safe write-once variables. Once a promise is created, threads may block waiting for it to be " { $emphasis "fulfilled" } "; at some point in the future, another thread may provide a value at which point all waiting threads are notified."
33 { $subsections
34     promise
35     <promise>
36     fulfill
37     ?promise
38     ?promise-timeout
39 } ;
40
41 ABOUT: "concurrency.promises"