class ConcurrentCharLoader
extends java.lang.Object
implements java.lang.Runnable
CharBucket instances using a Reader in a separate threadConcurrentCharInputReader,
CharBucket,
Entry| Modifier and Type | Field and Description |
|---|---|
private boolean |
active |
private java.lang.Thread |
activeExecution |
private java.util.concurrent.ArrayBlockingQueue<java.lang.Object> |
buckets |
private boolean |
closeOnStop |
private Entry<CharBucket> |
currentBucket |
private CharBucket |
end |
private java.lang.Exception |
error |
private boolean |
finished |
private FixedInstancePool<CharBucket> |
instances |
(package private) java.io.Reader |
reader |
| Constructor and Description |
|---|
ConcurrentCharLoader(java.io.Reader reader,
int bucketSize,
int bucketQuantity,
boolean closeOnStop)
Creates a
FixedInstancePool with a given amount of CharBucket instances and starts a thread to fill each one. |
| Modifier and Type | Method and Description |
|---|---|
CharBucket |
nextBucket()
Returns the next available bucket.
|
private int |
readBucket() |
(package private) void |
reportError() |
void |
run()
The
CharBucket loading process that executes in parallel until the input is completely read. |
private void |
setError(java.lang.Exception e) |
void |
stopReading()
Stops the
CharBucket loading process and closes the reader provided in the constructor of this class |
private final java.util.concurrent.ArrayBlockingQueue<java.lang.Object> buckets
private final CharBucket end
private final FixedInstancePool<CharBucket> instances
private Entry<CharBucket> currentBucket
private boolean finished
private boolean active
java.io.Reader reader
private java.lang.Thread activeExecution
private java.lang.Exception error
private final boolean closeOnStop
public ConcurrentCharLoader(java.io.Reader reader,
int bucketSize,
int bucketQuantity,
boolean closeOnStop)
FixedInstancePool with a given amount of CharBucket instances and starts a thread to fill each one.reader - The source of characters to extract and fill CharBucket instancesbucketSize - The size of each individual CharBucketbucketQuantity - The number of CharBucket instances used to extract characters from the given reader.closeOnStop - Indicates whether to automatically close the input when stopReading() is calledprivate int readBucket()
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOExceptionjava.lang.InterruptedExceptionpublic void run()
CharBucket loading process that executes in parallel until the input is completely read.
Once the end of the input is reached, the Reader instance provided in the constructor is closed.run in interface java.lang.Runnableprivate void setError(java.lang.Exception e)
public CharBucket nextBucket()
public void stopReading()
CharBucket loading process and closes the reader provided in the constructor of this classvoid reportError()