! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax ;
+USING: calendar concurrency.conditions help.markup help.syntax ;
IN: concurrency.flags
HELP: flag
{ $values { "flag" flag } }
{ $description "Creates a new flag." } ;
+HELP: lower-flag
+{ $values { "flag" flag } }
+{ $description "Attempts to lower a flag. If the flag has been raised previously, returns immediately, otherwise waits for it to be raised first." } ;
+
HELP: raise-flag
{ $values { "flag" flag } }
{ $description "Raises a flag, notifying any threads waiting on it. Does nothing if the flag has already been raised." } ;
{ $values { "flag" flag } }
{ $description "Waits for a flag to be raised. If the flag has already been raised, returns immediately." } ;
-HELP: lower-flag
-{ $values { "flag" flag } }
-{ $description "Attempts to lower a flag. If the flag has been raised previously, returns immediately, otherwise waits for it to be raised first." } ;
+HELP: wait-for-flag-timeout
+{ $values { "flag" flag } { "timeout" duration } }
+{ $description "Waits for a flag to be raised or throws a " { $link timed-out-error } " if the flag wasn't raised in time." } ;
ARTICLE: "concurrency.flags" "Flags"
"A " { $emphasis "flag" } " is a condition notification device which can be in one of two states: " { $emphasis "lowered" } " (the initial state) or " { $emphasis "raised" } "."
-USING: help.markup help.syntax help.tips io kernel listener
-ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.panes
-ui.operations ui.tools.common ui.tools.listener.completion vocabs
-vocabs.refresh words ;
+USING: help.markup help.syntax help.tips io kernel listener sequences
+ui.commands ui.gadgets.editors ui.gadgets.panes ui.operations
+ui.tools.common ui.tools.listener.completion vocabs vocabs.refresh
+words ;
IN: ui.tools.listener
HELP: <listener-gadget>
{ $values { "interactor" interactor } { "?" boolean } }
{ $description "We're busy if there's no thread to resume." } ;
+HELP: interactor-read
+{ $values { "interactor" interactor } { "lines" sequence } }
+{ $description "Implements the " { $link stream-readln } " generic for the interactor." } ;
+
HELP: wait-for-listener
{ $values { "listener" listener-gadget } }
-{ $description "Wait for the listener to start." } ;
+{ $description "Wait up to five seconds for the listener to start." } ;
ARTICLE: "ui-listener" "UI listener"
"The graphical listener adds input history and word and vocabulary completion. A summary with any outstanding error conditions is displayed before every prompt (see " { $link "ui.tools.error-list" } " for details)."
input>> dup popup>> or ;
: wait-for-listener ( listener -- )
- input>> flag>> wait-for-flag ;
+ input>> flag>> 5 seconds wait-for-flag-timeout ;
: listener-busy? ( listener -- ? )
input>> interactor-busy? ;