Qore Programming Language Reference Manual
0.9.1
|
This class provides a pair of streams connected through a buffer. More...
Public Member Methods | |
constructor (bool syncClose=True, timeout timeout_ms=-1, int bufferSize=4096) | |
Creates the StreamPipe. More... | |
PipeInputStream | getInputStream () |
Returns the input stream connected to the pipe. More... | |
PipeOutputStream | getOutputStream () |
Returns the output stream connected to the pipe. More... | |
This class provides a pair of streams connected through a buffer.
The input stream provides the bytes that are written to the output stream. Data should be written to and read from the streams by different threads. The pipe contains a buffer (the size can be specified in the constructor) - the reading operations on the input stream are blocked if the buffer is empty and the writing operations on the output stream are blocked if the buffer is full. The input stream reports the end of the stream once the output stream is closed using OutputStream::close() and all remaining data are read from the buffer. On the other hand, the OutputStream::close() method waits until PipeInputStream::finishClose() is called on the StreamPipe object which can be used to delay the main thread until all data are read from the pipe in the background thread.
Qore::StreamPipe::constructor | ( | bool | syncClose = True , |
timeout | timeout_ms = -1 , |
||
int | bufferSize = 4096 |
||
) |
Creates the StreamPipe.
syncClose | if True, then the output stream's close() method blocks until the input stream's finishClose() method is called |
timeout_ms | a timeout period with a resolution of milliseconds (a relative date/time value; integer arguments will be assumed to be milliseconds); if not given or negative the operations will never time out |
bufferSize | the size of the internal buffer |
PipeInputStream Qore::StreamPipe::getInputStream | ( | ) |
Returns the input stream connected to the pipe.
PipeOutputStream Qore::StreamPipe::getOutputStream | ( | ) |
Returns the output stream connected to the pipe.