public class ThreadAheadReadable extends ThreadAhead implements CharReadable
CharReadable, it's just that the reading happens in a separate thread, so when
a consumer wants to read(SectionedCharBuffer, int) more data it's already available, merely a memcopy away.Thread.State, Thread.UncaughtExceptionHandlerCharReadable.AdapterMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITYEMPTY| Modifier and Type | Method and Description |
|---|---|
long |
length() |
long |
position() |
int |
read(char[] into,
int offset,
int length)
Reads characters into the given array starting at
offset, reading length number of characters. |
SectionedCharBuffer |
read(SectionedCharBuffer buffer,
int from)
The one calling read doesn't actually read, since reading is up to the thread in here.
|
protected boolean |
readAhead() |
String |
sourceDescription() |
static CharReadable |
threadAhead(CharReadable actual,
int bufferSize) |
assertHealthy, close, parkAWhile, pokeReader, run, waitUntilReadAheadactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic SectionedCharBuffer read(SectionedCharBuffer buffer, int from) throws IOException
read in interface CharReadablebuffer - SectionedCharBuffer to read new data into.from - index into the buffer array where characters to save (compact) starts (inclusive).SectionedCharBuffer containing new data.IOException - if an I/O error occurs.public int read(char[] into,
int offset,
int length)
CharReadableoffset, reading length number of characters.
Similar to Reader.read(char[], int, int)read in interface CharReadableinto - char[] to read the data into.offset - offset to start reading into the char[].length - number of bytes to read maximum.protected boolean readAhead()
throws IOException
readAhead in class ThreadAheadIOExceptionpublic long position()
position in interface SourceTraceabilitypublic String sourceDescription()
sourceDescription in interface SourceTraceabilitypublic static CharReadable threadAhead(CharReadable actual, int bufferSize)
public long length()
length in interface CharReadableCopyright © 2016–2021 MWARE SOLUTIONS. All rights reserved.