Package org.jline.utils
Class NonBlockingPumpReader
- java.lang.Object
-
- java.io.Reader
-
- org.jline.utils.NonBlockingReader
-
- org.jline.utils.NonBlockingPumpReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public class NonBlockingPumpReader extends NonBlockingReader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
NonBlockingPumpReader.NbpWriter
-
Field Summary
Fields Modifier and Type Field Description private char[]
buffer
private boolean
closed
private int
count
private static int
DEFAULT_BUFFER_SIZE
(package private) java.util.concurrent.locks.ReentrantLock
lock
Main lock guarding all accessprivate java.util.concurrent.locks.Condition
notEmpty
Condition for waiting takesprivate java.util.concurrent.locks.Condition
notFull
Condition for waiting putsprivate int
read
private int
write
private java.io.Writer
writer
-
Fields inherited from class org.jline.utils.NonBlockingReader
EOF, READ_EXPIRED
-
-
Constructor Summary
Constructors Constructor Description NonBlockingPumpReader()
NonBlockingPumpReader(int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
java.io.Writer
getWriter()
protected int
read(long timeout, boolean isPeek)
Attempts to read a character from the input stream for a specific period of time.int
readBuffered(char[] b)
boolean
ready()
(package private) void
write(char[] cbuf, int off, int len)
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
buffer
private final char[] buffer
-
read
private int read
-
write
private int write
-
count
private int count
-
lock
final java.util.concurrent.locks.ReentrantLock lock
Main lock guarding all access
-
notEmpty
private final java.util.concurrent.locks.Condition notEmpty
Condition for waiting takes
-
notFull
private final java.util.concurrent.locks.Condition notFull
Condition for waiting puts
-
writer
private final java.io.Writer writer
-
closed
private boolean closed
-
-
Method Detail
-
getWriter
public java.io.Writer getWriter()
-
ready
public boolean ready()
- Overrides:
ready
in classjava.io.Reader
-
available
public int available()
- Overrides:
available
in classNonBlockingReader
-
read
protected int read(long timeout, boolean isPeek) throws java.io.IOException
Description copied from class:NonBlockingReader
Attempts to read a character from the input stream for a specific period of time.- Specified by:
read
in classNonBlockingReader
- Parameters:
timeout
- The amount of time to wait for the characterisPeek
-true
if the character read must not be consumed- Returns:
- The character read, -1 if EOF is reached, or -2 if the read timed out.
- Throws:
java.io.IOException
- if anything wrong happens
-
readBuffered
public int readBuffered(char[] b) throws java.io.IOException
- Specified by:
readBuffered
in classNonBlockingReader
- Throws:
java.io.IOException
-
write
void write(char[] cbuf, int off, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
-