Pipe.
More...
#include <base/io/Pipe.h>
Inherits Resource, InputStream, and OutputStream.
Pipe.
This class implements an anonymous pipe. MT-level is safe.
- Version
- 1.2
◆ Pipe()
Initializes an invalidated pipe object.
◆ ~Pipe()
◆ atEnd()
bool Pipe::atEnd |
( |
| ) |
const |
Returns true if the end of the stream has been reached.
◆ available()
unsigned int Pipe::available |
( |
| ) |
const |
|
virtual |
Returns the number of bytes that can be read or skipped over without blocking.
- Returns
- Available number of bytes in stream.
Implements InputStream.
◆ close()
Closes this pipe.
Implements Stream.
◆ flush()
Forces any buffered bytes to be written out.
Implements OutputStream.
◆ getBufferSize()
unsigned int Pipe::getBufferSize |
( |
| ) |
const |
Returns the size of the internal buffer of the pipe. The data may be interleaved when writing to the pipe from multiple threads simultaneously. To avoid the data being interleaved the packet size must not exceed this buffer size.
◆ make()
Creates a new pair of pipes.
◆ read()
unsigned int Pipe::read |
( |
uint8 * |
buffer, |
|
|
unsigned int |
size, |
|
|
bool |
nonblocking = false |
|
) |
| |
|
virtual |
Fills the specified buffer with bytes from the stream. In blocking mode the method does not return until all bytes have been read. In non-blocking mode the total bytes read may be any number below or equal to the requested number of bytes. Attempting to read beyond the end of a stream in blocking mode results in an EndOfFile exception.
- Parameters
-
buffer | The buffer to receive the bytes. |
size | The size of the buffer. |
nonblocking | Specifies that the method may not block. |
- Returns
- The actual number of bytes read from the stream.
Implements InputStream.
◆ skip()
unsigned int Pipe::skip |
( |
unsigned int |
count | ) |
|
|
virtual |
Skips a specified number of bytes. Blocks if asked to skip more bytes than currently available.
Implements InputStream.
◆ wait() [1/2]
void Pipe::wait |
( |
| ) |
const |
|
virtual |
Blocking wait for input to become available.
Implements InputStream.
◆ wait() [2/2]
bool Pipe::wait |
( |
unsigned int |
timeout | ) |
const |
|
virtual |
Blocking wait for input to become available.
- Parameters
-
timeout | The timeout periode in microseconds. |
- Returns
- True, if data is available. False, if the timeout periode expired.
Implements InputStream.
◆ write()
unsigned int Pipe::write |
( |
const uint8 * |
buffer, |
|
|
unsigned int |
size, |
|
|
bool |
nonblocking = false |
|
) |
| |
|
virtual |
Writes the specified number of bytes in the buffer to the stream. In blocking mode the method does not return until all bytes have been written. In non-blocking mode the total number of bytes written may be any number below or equal to the requested number of bytes.
- Parameters
-
buffer | The buffer containing the bytes to be written. |
size | The number of bytes to be written. |
nonblocking | Specifies that the method may not block. |
- Returns
- The actual number of bytes written to the stream.
Implements OutputStream.