1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax ;
7 { $class-description "A flag allows one thread to notify another when a condition is satisfied." } ;
10 { $values { "flag" flag } }
11 { $description "Creates a new 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." } ;
18 { $values { "flag" flag } }
19 { $description "Waits for a flag to be raised. If the flag has already been raised, returns immediately." } ;
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." } ;
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" } "."
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."
30 "Essentially, a flag can be thought of as a counting semaphore where the count never goes above one."
33 "Waiting for a flag to be raised:"
34 { $subsection raise-flag }
35 { $subsection wait-for-flag }
36 { $subsection lower-flag } ;
38 ABOUT: "concurrency.flags"