wait-for-input-available

Function

Package: mp

Arguments: streams &key wait-function whostate timeout

This lower-level function extends the capabilities of mp:process-wait and mp:process-wait-with-timeout to allow a process to wait for input from multiple streams and to wait for input from a file.

The streams argument may be a single element or a list of elements. Each element may be a stream object or a file descriptor obtained from the operating system (typically a small non-negative integer).

This function waits for input to become available on any of the streams, and when that happens a list of streams/fds (some subset of the given streams argument) that have input available is returned. Here have input available means a subsequent call to read-char or read-byte will immediately return without blocking. (It might return end-of-file status, however).

The default value for the wait-function keyword argument is #'stream-listen. This generic function has methods defined both for integer file descriptors and for terminal, socket, or other "interactive'' streams. When applied to a file stream, it will return t immediately. This function may be applied to streams that do not have a corresponding file descriptor, such as a window-stream (in Common Windows on Unix).

While waiting, the current process's whostate is set to the value specified for the whostate keyword argument, defaulting to "waiting for input", as if a process-wait or process-wait-with-timeout were being called. If a value is specified for the timeout keyword argument and no stream has input available before the timeout occurs, nil is returned. The value of the timeout argument (if it is specified) should be a non-negative real number. The units are seconds. Note that a value less than the granularity of the system will timeout immediately.

Note: This function is intended to replace most calls to the undocumented internal functions mp::watchfor and mp::unwatchfor.

See the discussion in the following sections in multiprocessing.htm for information on why not to use this function when waiting for input from a file. Note that the :os-threads and non :os-threads versions are discussed in different sections.

See also process-wait and waiting-for-input-available.

See multiprocessing.htm for general information on multiprocessing in Allegro CL.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.