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 booleanprivate intprivate static final int(package private) final ReentrantLockMain lock guarding all accessprivate final ConditionCondition for waiting takesprivate final ConditionCondition for waiting putsprivate intprivate intprivate final WriterFields inherited from class org.jline.utils.NonBlockingReader
EOF, READ_EXPIRED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()protected intread(long timeout, boolean isPeek) Attempts to read a character from the input stream for a specific period of time.intreadBuffered(char[] b, int off, int len, long timeout) booleanready()(package private) voidwrite(char[] cbuf, int off, int len) Methods inherited from class org.jline.utils.NonBlockingReader
peek, read, read, read, readBuffered, readBuffered, shutdownMethods 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:
availablein classNonBlockingReader
-
read
Description copied from class:NonBlockingReaderAttempts to read a character from the input stream for a specific period of time.- Specified by:
readin classNonBlockingReader- Parameters:
timeout- The amount of time to wait for the characterisPeek-trueif 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:
readBufferedin classNonBlockingReader- Throws:
IOException
-
write
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-