Class ConcurrentCharLoader
java.lang.Object
com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader
- All Implemented Interfaces:
Runnable
A concurrent character loader for loading a pool of
CharBucket
instances using a Reader
in a separate thread- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private Thread
private final ArrayBlockingQueue<Object>
private final boolean
private Entry<CharBucket>
private final CharBucket
private Exception
private boolean
private final FixedInstancePool<CharBucket>
(package private) Reader
-
Constructor Summary
ConstructorsConstructorDescriptionConcurrentCharLoader
(Reader reader, int bucketSize, int bucketQuantity, boolean closeOnStop) Creates aFixedInstancePool
with a given amount ofCharBucket
instances and starts a thread to fill each one. -
Method Summary
Modifier and TypeMethodDescriptionReturns the next available bucket.private int
(package private) void
void
run()
TheCharBucket
loading process that executes in parallel until the input is completely read.private void
void
Stops theCharBucket
loading process and closes the reader provided in the constructor of this class
-
Field Details
-
buckets
-
end
-
instances
-
currentBucket
-
finished
private boolean finished -
active
private boolean active -
reader
Reader reader -
activeExecution
-
error
-
closeOnStop
private final boolean closeOnStop
-
-
Constructor Details
-
ConcurrentCharLoader
Creates aFixedInstancePool
with a given amount ofCharBucket
instances and starts a thread to fill each one.- Parameters:
reader
- The source of characters to extract and fillCharBucket
instancesbucketSize
- The size of each individualCharBucket
bucketQuantity
- The number ofCharBucket
instances used to extract characters from the given reader.closeOnStop
- Indicates whether to automatically close the input whenstopReading()
is called
-
-
Method Details
-
readBucket
- Throws:
IOException
InterruptedException
-
run
public void run()TheCharBucket
loading process that executes in parallel until the input is completely read. Once the end of the input is reached, theReader
instance provided in the constructor is closed. -
setError
-
nextBucket
Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.- Returns:
- the next available bucket.
-
stopReading
public void stopReading()Stops theCharBucket
loading process and closes the reader provided in the constructor of this class -
reportError
void reportError()
-