Package hudson.remoting
Class FastPipedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- hudson.remoting.FastPipedInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class FastPipedInputStream extends InputStream
This class is equivalent tojava.io.PipedInputStream
. In the interface it only adds a constructor which allows for specifying the buffer size. Its implementation, however, is much simpler and a lot more efficient than its equivalent. It doesn't rely on polling. Instead it uses proper synchronization with its counterpartFastPipedOutputStream
.- Author:
- WD
- See Also:
- 4404700,
FastPipedOutputStream
-
-
Constructor Summary
Constructors Constructor Description FastPipedInputStream()
Creates an unconnected PipedInputStream with a default buffer size.FastPipedInputStream(FastPipedOutputStream source)
Creates a PipedInputStream with a default buffer size and connects it tosource
.FastPipedInputStream(FastPipedOutputStream source, int bufferSize)
Creates a PipedInputStream with buffer sizebufferSize
and connects it tosource
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
void
connect(FastPipedOutputStream source)
protected void
finalize()
void
mark(int readLimit)
boolean
markSupported()
int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
FastPipedInputStream
public FastPipedInputStream()
Creates an unconnected PipedInputStream with a default buffer size.
-
FastPipedInputStream
public FastPipedInputStream(FastPipedOutputStream source) throws IOException
Creates a PipedInputStream with a default buffer size and connects it tosource
.- Throws:
IOException
- It was already connected.
-
FastPipedInputStream
public FastPipedInputStream(FastPipedOutputStream source, int bufferSize) throws IOException
Creates a PipedInputStream with buffer sizebufferSize
and connects it tosource
.- Throws:
IOException
- It was already connected.
-
-
Method Detail
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- The pipe is not connected.
-
connect
public void connect(FastPipedOutputStream source) throws IOException
- Throws:
IOException
- The pipe is already connected.
-
finalize
protected void finalize() throws Throwable
-
mark
public void mark(int readLimit)
- Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(@NonNull byte[] b) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
public int read(@NonNull byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
- The pipe is not connected.
-
-