Package org.jenkinsci.remoting.util
Class ByteBufferQueueInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.jenkinsci.remoting.util.ByteBufferQueueInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class ByteBufferQueueInputStream extends InputStream
AnInputStream
backed by aByteBufferQueue
. Assumes that the backingByteBufferQueue
will not be updated by another thread during calls toread()
so all methods are non-blocking and an emptyByteBufferQueue
is deemed equivalent to end of stream.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description ByteBufferQueueInputStream(ByteBufferQueue queue)
Constructs a new instance.ByteBufferQueueInputStream(ByteBufferQueue queue, int length)
Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
mark(int readlimit)
boolean
markSupported()
int
read()
int
read(byte[] b, int off, int len)
void
reset()
long
skip(long n)
-
Methods inherited from class java.io.InputStream
close, nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
ByteBufferQueueInputStream
public ByteBufferQueueInputStream(ByteBufferQueue queue)
Constructs a new instance.- Parameters:
queue
- the backingByteBufferQueue
.
-
ByteBufferQueueInputStream
public ByteBufferQueueInputStream(ByteBufferQueue queue, int length)
Constructs a new instance.- Parameters:
queue
- the backingByteBufferQueue
.length
- the limit of bytes to take from the backing queue.
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(@NonNull byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classInputStream
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
-