Package jmri.util
Class ImmediatePipedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.PipedOutputStream
-
- jmri.util.ImmediatePipedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ImmediatePipedOutputStream extends java.io.PipedOutputStream
Makes a workaround for standardPipedOutputStreamwait.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 callsink.receive, but does notnotify()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.
-
-
Constructor Summary
Constructors Constructor Description ImmediatePipedOutputStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Constructor Detail
-
ImmediatePipedOutputStream
public ImmediatePipedOutputStream()
-
-
Method Detail
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
writein classjava.io.PipedOutputStream- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Overrides:
writein classjava.io.PipedOutputStream- Throws:
java.io.IOException
-
-