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 standardPipedOutputStream
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 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 void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Constructor Detail
-
ImmediatePipedOutputStream
public ImmediatePipedOutputStream()
-
-
Method Detail
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.PipedOutputStream
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.PipedOutputStream
- Throws:
java.io.IOException
-
-