|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.emory.mathcs.util.io.BufferedPipe
In-memory pipe that enables buffered sequential data transfer between threads. Pipe has two ends: source and sink. Source is an output stream into which the writer writes bytes. Sink is the input stream from which reader reads bytes. Data that was wrote to the source but not yet read from the sink are kept in a pipe buffer.
This implementation features dynamic buffer sizing, so that memory consumption is minimized if there is little data to buffer. Buffer is upsized if more space is needed and downsized when data is read. Resizing never causes data copying.
This implementation supports concurrent reads and writes.
Memory usage limits and allocation policy can be controlled via provided
Allocator
. For example, multiple pipes can share allocator with
fixed maximum memory footprint, thus limiting total memory used for I/O
buffering.
InProcServerSocket
,
InProcSocket
Field Summary | |
protected java.io.InputStream |
sink
Sink of the pipe. |
protected java.io.OutputStream |
source
Source of the pipe. |
Constructor Summary | |
BufferedPipe()
Creates a new pipe with a default shared allocator with 10 MB footprint limit, and a default initial chunk size of 8 KB. |
|
BufferedPipe(Allocator allocator)
Creates a new pipe with specified allocator and a default initial chunk size of 8 KB. |
|
BufferedPipe(Allocator allocator,
int chunksize)
Creates a new pipe with specified allocator and initial chunk size. |
|
BufferedPipe(int chunksize)
Creates a new pipe with a default shared allocator with 10 MB footprint limit, and with specified initial chunk size. |
Method Summary | |
long |
length()
Returns the current length of the pipe, that is, the number of bytes buffered and available for read. |
java.io.InputStream |
sink()
Returns the sink of this pipe, from where reader can read data. |
java.io.OutputStream |
source()
Returns the source of this pipe, where writer can write data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final java.io.OutputStream source
protected final java.io.InputStream sink
Constructor Detail |
public BufferedPipe()
public BufferedPipe(int chunksize)
chunksize
- the initial chunk size.public BufferedPipe(Allocator allocator)
allocator
- allocator that will provide memory buffers for this
pipepublic BufferedPipe(Allocator allocator, int chunksize)
allocator
- allocator that will provide memory buffers for this
pipechunksize
- the initial chunk sizeMethod Detail |
public java.io.OutputStream source()
public java.io.InputStream sink()
public long length()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |