Class NonBlockingInputStreamImpl

java.lang.Object
java.io.InputStream
org.jline.utils.NonBlockingInputStream
org.jline.utils.NonBlockingInputStreamImpl
All Implemented Interfaces:
Closeable, AutoCloseable

public class NonBlockingInputStreamImpl extends NonBlockingInputStream
This class wraps a regular input stream and allows it to appear as if it is non-blocking; that is, reads can be performed against it that timeout if no data is seen for a period of time. This effect is achieved by having a separate thread perform all non-blocking read requests and then waiting on the thread to complete.

VERY IMPORTANT NOTES

  • This class is not thread safe. It expects at most one reader.
  • The shutdown() method must be called in order to shut down the thread that handles blocking I/O.