Pipe Class Reference

#include <Pt/System/Pipe.h>

Pair of IODevice endpoints that form a half-duplex pipe. More...

Inherits NonCopyable.

Public Member Functions

 Pipe ()
 Creates the pipe with two IODevices.
 ~Pipe ()
 Destructor.
IODevice & out ()
 Endpoint of the pipe to read from.
const IODevice & out () const
 Endpoint of the pipe to read from.
IODevice & in ()
 Endpoint of the pipe to write to.
const IODevice & in () const
 Endpoint of the pipe to write to.

Detailed Description

A pipe is two IODevice objects created together. Bytes written to in() are read from out() in the same order. The constructor opens both ends. The destructor closes them.

Whether a write blocks until a read consumes data is system-dependent. Some platforms buffer a limited number of bytes between the ends. That buffer must not be assumed. Treat a write as complete only when write() or endWrite() returns.

Each end is a Selectable. Attach out() to an EventLoop to read without blocking the thread. Attach in() to write the same way.

Constructor & Destructor Documentation

◆ Pipe()

Pipe ( )
explicit

The default constructor will create the pipe and the appropriate IODevices to read and write to the pipe.

◆ ~Pipe()

~Pipe ( )

Destroys the pipe and closes the internal IODevices.