[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
1Pipelining streams or Point, Counter Point0
Date: Fri, 23 Oct 87 17:48 EDT
From: J. Scott Penberthy <JSP@IBM.COM>
1 jsp: Here's an excerpt from my original message:
(defun bad-pipeline-implementation (f1 f2)
(funcall
f2
(with-output-to-stream (s)
(funcall f1 s))))
However, this hack creates huge temporary strings. In addition, it
needlessly gathers all of the output from the first function before
sending it as input to the second function. Does anyone know of a
better way to solve this problem?
0Coroutine solve this.
1 In particular, does anyone have a
solution that permits concurrent execution of the pipelined functions?
0Coroutine streams are not, strictly speaking, concurrent.
However, they *do* provide for interleaved execution.
The source side runs just long enough to fill up the
buffer, then the input side runs just long enough to
empty it again, and back to the output side.
If the only way the two programs have of communicating is
by the coroutine stream, they can't tell the difference.
Coroutine streams are useful much much more often in
our system than pipes. In fact, one barrier to documenting
pipes is that it is rather difficult to construct a non-silly
example where pipes are to be preferred over coroutine streams.
In particular, nearly every Unixoid use of pipes is better
done with coroutine streams.