美文网首页
Swift - Pipe

Swift - Pipe

作者: 我阿郑 | 来源:发表于2022-01-26 18:30 被阅读0次

苹果原文文档

Pipe

A one-way communications channel between related processes.

相关进程之间的单向通信通道

class Pipe : NSObject

Overview

Pipe objects provide an object-oriented interface for accessing pipes.
An Pipe object represents both ends of a pipe and enables communication through the pipe. A pipe is a one-way communications channel between related processes; one process writes data, while the other process reads that data. The data that passes through the pipe is buffered; the size of the buffer is determined by the underlying operating system. Pipe is an abstract class, the public interface of a class cluster.

Pipe对象为访问管道提供了一个面向对象的接口。Pipe对象表示管道的两端,并且可以通过管道进行通信。管道是相关进程之间的单向通信通道;一个进程写入数据,另一个进程读取数据。通过管道的数据被缓冲;缓冲区的大小由底层操作系统决定。Pipe是一个抽象类,一个类簇的公共接口。

Topics

Getting the File Handles for a Pipe

获取管道的文件句柄

// Instance Property 实例属性

var fileHandleForReading: FileHandle
// The receiver's read file handle.
接收器的读取文件句柄

var fileHandleForWriting: FileHandle
// The receiver's write file handle.
接收器的写文件句柄

fileHandleForReading

The receiver's read file handle.

var fileHandleForReading: FileHandle { get }

Discussion

The descriptor represented by this object is deleted, and the object itself is automatically deallocated when the receiver is deallocated.

该对象所代表的描述符被删除,而对象本身在接收器被释放时也被自动释放。

You use the returned file handle to read from the pipe using NSFileHandle's read methods — availableData, readDataToEndOfFile(), and readData(ofLength:)

使用返回的文件句柄来从管道读取数据,使用NSFileHandle 的read方法: availableData, readDataToEndOfFile(), 和readData(ofLength:)

You don’t need to send closeFile() to this object or explicitly release the object after you have finished using it.

您无需在使用完对象后向该对象发送 closeFile() 或显式释放该对象

fileHandleForWriting

The receiver's write file handle.

var fileHandleForWriting: FileHandle { get }

Discussion

This object is automatically deallocated when the receiver is deallocated.

当接收者被释放时,这个对象会被自动释放。

You use the returned file handle to write to the pipe using NSFileHandle's write(_:)method. When you are finished writing data to this object, send it a closeFile()message to delete the descriptor. Deleting the descriptor causes the reading process to receive an end-of-data signal (an empty NSData object).

使用返回的文件句柄来写入管道,使用NSFileHandle's 的 write(_:) 方法。
当您完成向该对象写入数据后,向其发送 closeFile() 消息以删除描述符。
删除描述符会导致读取过程接收到数据结束信号(一个空的 NSData 对象)

相关文章

  • Swift - Pipe

    苹果原文文档[%5Bhttps://developer.apple.com/documentation/found...

  • 聊聊storagetapper的pipe

    序 本文主要研究一下storagetapper的pipe Pipe storagetapper/pipe/pipe...

  • NIO十二-Pipe

    Java NIO Pipe Creating a Pipe Writing to a Pipe Reading f...

  • Angular Pipe

    Angular Pipe is object, not function, when pipe created, ...

  • python 学习笔记(Queue & Pipe 进程间的通讯)

    Pipe multiprocessing.Pipe()即管道模式,调用Pipe()返回管道的两端的Connecti...

  • 自定义pipe

    自定义pipe pipe说明:(自定义pipe只需实现 PipeTransform接口的transform方法即可 )

  • Linux IPC

    Pipe Named Pipe Signal Semaphore Message Queue Memory Sha...

  • Linux IPC

    Pipe/FIFO(named Pipe)/Semaphore/Message Queue/Share Memor...

  • 管道

    man 7 PIPE pipe和FIFO介绍pipe匿名管道,只能用于有亲缘关系的进程间通信FIFO命名管道,任意...

  • Android进程间通信机制-管道

    PIPE和FIFO的使用及原理 PIPE和FIFO都是指管道,只是PIPE独指匿名管道,FIFO独指有名管道,我们...

网友评论

      本文标题:Swift - Pipe

      本文链接:https://www.haomeiwen.com/subject/icgnhrtx.html