Package org.jline.utils
Class NonBlocking.NonBlockingInputStreamReader
java.lang.Object
java.io.Reader
org.jline.utils.NonBlockingReader
org.jline.utils.NonBlocking.NonBlockingInputStreamReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
- Enclosing class:
NonBlocking
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufferprivate final CharBufferprivate final CharsetDecoderprivate final NonBlockingInputStreamFields inherited from class org.jline.utils.NonBlockingReader
closed, EOF, READ_EXPIRED -
Constructor Summary
ConstructorsConstructorDescriptionNonBlockingInputStreamReader(NonBlockingInputStream inputStream, Charset encoding) NonBlockingInputStreamReader(NonBlockingInputStream input, CharsetDecoder decoder) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this reader and marks it as closed.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) voidshutdown()Shuts down the thread that is handling blocking I/O.Methods inherited from class org.jline.utils.NonBlockingReader
available, checkClosed, peek, read, read, read, readBuffered, readBufferedMethods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Field Details
-
input
-
decoder
-
bytes
-
chars
-
-
Constructor Details
-
NonBlockingInputStreamReader
-
NonBlockingInputStreamReader
-
-
Method Details
-
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
-
shutdown
public void shutdown()Description copied from class:NonBlockingReaderShuts down the thread that is handling blocking I/O.This method terminates the background thread that is used to handle blocking I/O operations. This allows the application to clean up resources and prevent thread leaks when the reader is no longer needed.
Note that if the thread is currently blocked waiting for I/O, it will not actually shut down until the I/O is received or the thread is interrupted. In some implementations, this method may interrupt the thread to force it to shut down immediately.
After calling this method, the reader should not be used anymore, as subsequent read operations may fail or block indefinitely.
- Overrides:
shutdownin classNonBlockingReader
-
close
Description copied from class:NonBlockingReaderCloses this reader and marks it as closed.Subsequent read operations behavior depends on the
PROP_CLOSE_MODEsetting:"strict"- ThrowClosedException"warn"- Log a warning but continue (default in JLine 3.x)"lenient"- Silently allow access
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classNonBlockingReader- Throws:
IOException- if an I/O error occurs
-