For faster navigation, this Iframe is preloading the Wikiwand page for 管道 (软件).

管道 (软件)

管道(pipeline),本源是使用消息传递进程间通信机制,它构成自链接起来的处理元素(进程线程协程函数等),它们被安置为每个元素的输出都是下一个元素的输入;这个名字类比于物理上的管道运输。在连贯的元素之间,通常会提供一定数量的缓冲区。在管道中流动的资讯,经常是记录字节(stream),而管道的元素可以叫做过滤器英语Filter (software)。将元素连接成管道类似于函数复合英语Function composition (computer science)。在软件工程中,称之为管道与过滤器设计模式[1]

概述

[编辑]

管道的概念是在Unix的发源地贝尔实验室Douglas McIlroy在Unix开发期间主张的[2][3]。与Unix的管道有关的更早期独立工作是Ken Lochner在1960年代为Dartmouth分时系统英语Dartmouth Time Sharing System开发的“通信文件”[4][5]Tony Hoare在1978年提出的通信顺序进程(CSP),进一步发展了McIlroy的管道,但它用于通信的无缓冲区通道不是头等对象[6]CMS管道英语CMS Pipelines是开始于1980年的将管道想法向IBMVM/CMS英语VM (operating system)z/OS系统的移植[7]

狭窄些说,管道是线性的和单向的,最典型的是Unix shell最初提供的管道语法。但是这个术语有时也应用于更一般性的流(flow)。例如,一个基本上单向的管道,可以有在另一个方向上一些通信,叫做“返回通道”或“反向通道”,就像在lexer hack英语lexer hack中那样,也有管道可以是完全双向的。有着单向树和有向无环图拓扑的流[8][9],由于没有环路而相对简单,使得它们表现得类似于(线性的)管道,因此也可以宽泛的称为“管道”[10]

除了基于字节流(stream)的管道,还有对象管道。在对象管道中,处理元素输出对象而非文本。Windows PowerShell包含了一种内部的对象管道,在PowerShell运行时系统之内于函数之间传输.NET对象。在Limbo编程语言中的通道,是这种隐喻英语Scientific community metaphor的另一个例子。

管道和过滤器英语Filter (software),可以被看作使用字节流作为数据对象的一种形式的函数式编程;更具体的说,它们可以被看作是特定形式的I/O单子[11]

参见

[编辑]

注释

[编辑]
  1. ^ Jorge L. Ortega-Arjona. The Pipes and Filters Pattern. A Functional Parallelism Architectural Pattern for Parallel Programming. January 2005.
  2. ^ Mahoney, Michael S. The Unix Oral History Project: Release.0, The Beginning. [2020-05-04]. (原始内容存档于2021-04-21). McIlroy: It was one of the only places where I very nearly exerted managerial control over Unix, was pushing for those things, yes. 
  3. ^ Advice for pipe from M. D. McIlroy.. [2020-05-04]. (原始内容存档于2021-02-22). 
  4. ^ 存档副本. [2020-05-05]. (原始内容存档于2021-02-25). 
  5. ^ The Evolution of the Unix Time-sharing System页面存档备份,存于互联网档案馆).
  6. ^ Russ Cox, Bell Labs and CSP Threads页面存档备份,存于互联网档案馆).
  7. ^ VM and the VM Community, Melinda Varian (PDF). [2020-05-04]. (原始内容存档 (PDF)于2021-04-21). 
  8. ^ Tom Duff. Rc — The Plan 9 Shell页面存档备份,存于互联网档案馆). 1990.
  9. ^ Diomidis Spinellis, Marios Fragkoulis. Extending Unix Pipelines to DAGs. April 2017. IEEE Transactions on Computers PP(99):1-1. 
  10. ^ dgsh — directed graph shell页面存档备份,存于互联网档案馆).
  11. ^ "Monadic I/O and UNIX shell programming". [2020-05-04]. (原始内容存档于2020-11-09). 

外部链接

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
管道 (软件)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?