Package org.jline.utils
Class NonBlockingPumpReader
java.lang.Object
java.io.Reader
org.jline.utils.NonBlockingReader
org.jline.utils.NonBlockingPumpReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final char[]
private boolean
private int
private static final int
(package private) final ReentrantLock
Main lock guarding all accessprivate final Condition
Condition for waiting takesprivate final Condition
Condition for waiting putsprivate int
private int
private final Writer
Fields inherited from class org.jline.utils.NonBlockingReader
EOF, READ_EXPIRED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
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, int off, int len, long timeout) boolean
ready()
(package private) void
write
(char[] cbuf, int off, int len) Methods inherited from class org.jline.utils.NonBlockingReader
peek, read, read, read, readBuffered, readBuffered, shutdown
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, reset, skip, transferTo
-
Field Details
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE- See Also:
-
buffer
private final char[] buffer -
read
private int read -
write
private int write -
count
private int count -
lock
Main lock guarding all access -
notEmpty
Condition for waiting takes -
notFull
Condition for waiting puts -
writer
-
closed
private boolean closed
-
-
Constructor Details
-
NonBlockingPumpReader
public NonBlockingPumpReader() -
NonBlockingPumpReader
public NonBlockingPumpReader(int bufferSize)
-
-
Method Details
-
getWriter
-
ready
public boolean ready() -
available
public int available()- Overrides:
available
in classNonBlockingReader
-
read
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:
IOException
- if anything wrong happens
-
readBuffered
- Specified by:
readBuffered
in classNonBlockingReader
- Throws:
IOException
-
write
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-