Package jmri.util

Class ImmediatePipedOutputStream

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

    public class ImmediatePipedOutputStream
    extends java.io.PipedOutputStream
    Makes a workaround for standard PipedOutputStream wait.

    The PipedInputStream.read(), in case the receive buffer is empty at the time of the call, waits for up to 1000ms. PipedOutputStream.write(int) does call sink.receive, but does not notify() the sink object so that read's wait() terminates.

    As a result, the read side of the pipe waits full 1000ms even though data become available during the wait.

    The workaround is to simply PipedOutputStream.flush() after write, which returns from wait()s immediately.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.PipedOutputStream

        close, connect, flush
      • Methods inherited from class java.io.OutputStream

        nullOutputStream, write
      • Methods inherited from class java.lang.Object

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

      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.PipedOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.PipedOutputStream
        Throws:
        java.io.IOException