Class NonBlockingPumpReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

    public class NonBlockingPumpReader
    extends NonBlockingReader
    • 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 access
      private java.util.concurrent.locks.Condition notEmpty
      Condition for waiting takes
      private java.util.concurrent.locks.Condition notFull
      Condition for waiting puts
      private int read  
      private int write  
      private java.io.Writer writer  
    • 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)  
      • Methods inherited from class java.io.Reader

        mark, markSupported, nullReader, read, read, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
    • Constructor Detail

      • NonBlockingPumpReader

        public NonBlockingPumpReader()
      • NonBlockingPumpReader

        public NonBlockingPumpReader​(int bufferSize)
    • Method Detail

      • getWriter

        public java.io.Writer getWriter()
      • ready

        public boolean ready()
        Overrides:
        ready in class java.io.Reader
      • 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 class NonBlockingReader
        Parameters:
        timeout - The amount of time to wait for the character
        isPeek - 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:
        java.io.IOException - if anything wrong happens
      • readBuffered

        public int readBuffered​(char[] b)
                         throws java.io.IOException
        Specified by:
        readBuffered in class NonBlockingReader
        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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException