[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pipelining streams
[Added customer-reports since there are bugs here]
Date: Wed, 21 Oct 87 10:48 EDT
From: J. Scott Penberthy <JSP@IBM.COM>
Has anyone had any luck trying to 1pipeline0 streams? Suppose that you
had a function 2foo0 that takes an input stream as an argument. Further,
suppose you had another function 2bar0 that takes an output stream as an
argument. For example,
(defun 2foo0 (input-stream)
(read-and-process-stream input-stream))
(defun 2bar0 (output-stream)
(create-garbage-and-write-to output-stream))
I'd like to be able to call a third function, 2pipeline0, that would take the
output generated by 2bar0 and send it as input to the function 2foo0. For
example,
(pipeline bar foo)
should do the right thing.
[ . . . ]
I was going to suggest:
(defun 2pipeline 0(f1 f2)
(funcall f1 (si:make-coroutine-input-stream f2)))
but, first off, 2si:make-coroutine-input-stream0 seems to have been moved
from SI to CLI without anybody telling the documetnation department, and
secondly, it doesn't work. using 2cli::make-coroutine-input-stream
0rather than 2si:make-coroutine-input-stream0 will work with the following
patch:
;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: ZL-USER; Base: 10; Patch-File: T -*-
;;; Patch file for Loc version 197.11
;;; Reason: Function 2cli::make-coroutine-unidirectional-stream-internal0: Use character buffer, not
;;; (unsigned 8) buffer.
;;; Written by 7thSon, 10/22/87 10:05:22
;;; while running on Fluttering Ashen Moth from FEP0:>inc-who-calls-from-inc-spar.load.1
;;; with Genera 7.1, Print Spooler 3.10, IP-TCP 52.16, ILA-NFS 3.2, Local-Mods 197.9,
;;; Experimental Seventh son 3.9, Experimental Printer-Mods 1.0,
;;; microcode 3640-FPA-MIC 396, FEP 127, FEP0:>v127-lisp.flod(55),
;;; FEP0:>v127-loaders.flod(55), FEP0:>v127-debug.flod(34), FEP0:>v127-info.flod(55),
;;; Machine serial number 4289,
;;; Decorate Hack (from 7THSON:PUBLIC-HACKS;THERMOMETER.LISP.11),
;;; Editing a file tells you the source category. (from 7THSON:PUBLIC-HACKS;NEW-CATEGORIZE-SOURCE.LISP.9),
;;; Electric Character Style Lock enhancements (from 7THSON:PUBLIC-HACKS;ELECTRIC-STYLE-LOCK.LISP.3),
;;; Show progress in Show Processes (from 7THSON:HACKS;SHOW-PROCESSES.LISP.3),
;;; Make the print spooler work even if no one is logged in on the server. (from SYS:FLAIR;PRINT-SPOOLER-PATCH.LISP.2)
;;; Misc print server bug fixes (from SYS:FLAIR;PRINT-SPOOLER-PATCH.LISP.2).
;=====================================
(SYSTEM-INTERNALS:BEGIN-PATCH-SECTION)
(SYSTEM-INTERNALS:PATCH-SECTION-SOURCE-FILE "SYS:IO;USEFUL-STREAMS.LISP.13")
(SYSTEM-INTERNALS:PATCH-SECTION-ATTRIBUTES
"-*- Mode: LISP; Package: CLI; Lowercase: Yes; Syntax: Common-lisp -*-")
(defun make-coroutine-unidirectional-stream-internal
(flavor-1 flavor-2 function arguments
&optional (buffer-size 1000) (element-type 2#+ignore0 '(unsigned-byte 8) 2'character0))
(let* ((buffer (allocate-resource 'coroutine-stream-buffer buffer-size element-type))
(stream-1 (make-instance flavor-1 :buffer buffer))
(stream-2 (make-instance flavor-2 :buffer buffer)))
(setup-coroutine-streams stream-1 stream-2 function arguments)))
I also note that there's undocumented code in the same file for "pipes",
but in 2 minutes of playing, I couldn't make them work. I tried this:
(defun 2pipeline2 0(f1 f2)
(multiple-value-bind (s1 s2)
(sys:make-unidirectional-pipe)
(while-in-background "Run background function"
(funcall f2 s2))
(funcall f1 s1)))
where 2while-in-background0 is a local hack. ~shrug~ There's also this
comment in the file 1above0 the code for pipes:
;; Improvements to be made to the above:
;; COROUTINE-STREAM-FOOTHOLD should set up a restart handler which aborts
;; back to the initial stack group.
;; Handle other stack group states
;; Implement pipes