]> gitweb.factorcode.org Git - factor.git/blob - extra/concurrency/flags/flags-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / extra / concurrency / flags / flags-docs.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax ;
4 IN: concurrency.flags
5
6 HELP: flag
7 { $class-description "A flag allows one thread to notify another when a condition is satisfied." } ;
8
9 HELP: <flag>
10 { $values { "flag" flag } }
11 { $description "Creates a new flag." } ;
12
13 HELP: raise-flag
14 { $values { "flag" flag } }
15 { $description "Raises a flag, notifying any threads waiting on it. Does nothing if the flag has already been raised." } ;
16
17 HELP: wait-for-flag
18 { $values { "flag" flag } }
19 { $description "Waits for a flag to be raised. If the flag has already been raised, returns immediately." } ;
20
21 HELP: lower-flag
22 { $values { "flag" flag } }
23 { $description "Attempts to lower a flag. If the flag has been raised previously, returns immediately, otherwise waits for it to be raised first." } ;
24
25 ARTICLE: "concurrency.flags" "Flags"
26 "A " { $emphasis "flag" } " is a condition notification device which can be in one of two states: " { $emphasis "lowered" } " (the initial state) or " { $emphasis "raised" } "."
27 $nl
28 "The flag can be raised at any time; raising a raised flag does nothing. Lowering a flag if it has not been raised yet will wait for another thread to raise the flag."
29 $nl
30 "Essentially, a flag can be thought of as a counting semaphore where the count never goes above one."
31 { $subsection flag }
32 { $subsection flag? }
33 "Waiting for a flag to be raised:"
34 { $subsection raise-flag }
35 { $subsection wait-for-flag }
36 { $subsection lower-flag } ;
37
38 ABOUT: "concurrency.flags"