A Pipe to the Future

Michael van der Gulik mikevdg at gmail.com
Thu Sep 6 00:56:44 UTC 2007


On 9/6/07, Peter William Lount <peter at smalltalk.org> wrote:
>
> Hi,
>
> I am wondering if the following would be possible and if so how?
>
> aProcess := [ "a block that pumps out continuous values"] fork.
> bProcess := [:in | in someOperation ] fork.
>
> "pipe the results of process a into process b like in unix shell"
> aProcess asPipeInto: bProcess.
>
> or
>
> aProcess | bProcess
>
>
It's easier to do it directly.

keepGoing := true.
s := SharedQueue new.
[ 1 to: 100 do: [ :each | s nextPut: each ] ] fork.
[ [keepGoing] whileTrue: [Transcript show: s next asString, ' ']. ] fork.

And then:
keepGoing := false. "To stop the second process."

The SharedQueue acts like the pipe. You could make your own class to add a
layer of abstraction, but this would only be worthwhile if you are having
difficulty with the complexity.

Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070906/0c291bc0/attachment.htm


More information about the Squeak-dev mailing list