|Constructor and Description|
Constructs a new
|Modifier and Type||Method and Description|
Returns the underlying
Returns the buffer size, real bytes
Returns the current delay in ticks.
Sets a new delay in ticks.
Sets whether this
Sets the non-blocking flag.
Called when a tick event is fired.
public DelayedInputStream(TickSource t, InputStream real, long delay, int bufferSize)
DelayedInputStreamwith the given parameters.
t- the tick source to use
real- the underlying
InputStreamto read data from
delay- the delay (real ticks) to introduce to data
bufferSize- the buffer size to use. The implementation has to store read bytes real an intermediate buffer. The buffer must be large enough to store the data. Note that data which cannot be stored into the buffer because of its overflow will have a higher delay, which is why the buffer should be significantly higher than the expected data arrivel rate (times the expected interval of reading from this stream).
public void close() throws IOException
public int read(byte b, int off, int len) throws IOException
public int read(byte b) throws IOException
public void tick(long tick)
Long.MAX_VALUEis followed by
Long.MIN_VALUE. Furthermore, it is guaranteed that ticks do not overlap each other, ie. no two threads will enter the same object's
TickListener.tick(long)at the same time.
public int available() throws IOException
public void setDelay(long delay)
public long getDelay()
public int getBufferSize()
public InputStream getBaseStream()
public TickSource getTickSource()
TickSourcethis stream uses.
public void setNonBlocking(boolean nonBlocking)
nonBlocking- whether the stream should be in non-blocking mode (see
public void setEofDetection(boolean eofDetection)
DelayedInputStreamshould employ EOF detection. If this flag is set to
true, this stream starts showing non-deterministic behavior (in general), since a new thread is spawned for continuous EOF detection which might or might not wake up before a certain tick to report a new byte. Without EOF detection, EOF is not reported to the caller at all. If this flag is set to
falsewhile an EOF detector thread is running, the thread might finish at some undefined point in future, ie. setting this flag to false only prevents new EOF detector threads from spawning.
eofDetection- if EOF detection should be employed (impllies non-deterministisc behavior)
Copyright © 2015. All rights reserved.