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 booleanprivate Threadprivate final ArrayBlockingQueue<Object> private final booleanprivate Entry<CharBucket> private final CharBucketprivate Exceptionprivate booleanprivate final FixedInstancePool<CharBucket> (package private) Reader -
Constructor Summary
ConstructorsConstructorDescriptionConcurrentCharLoader(Reader reader, int bucketSize, int bucketQuantity, boolean closeOnStop) Creates aFixedInstancePoolwith a given amount ofCharBucketinstances and starts a thread to fill each one. -
Method Summary
Modifier and TypeMethodDescriptionReturns the next available bucket.private int(package private) voidvoidrun()TheCharBucketloading process that executes in parallel until the input is completely read.private voidvoidStops theCharBucketloading 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 aFixedInstancePoolwith a given amount ofCharBucketinstances and starts a thread to fill each one.- Parameters:
reader- The source of characters to extract and fillCharBucketinstancesbucketSize- The size of each individualCharBucketbucketQuantity- The number ofCharBucketinstances used to extract characters from the given reader.closeOnStop- Indicates whether to automatically close the input whenstopReading()is called
-
-
Method Details
-
readBucket
- Throws:
IOExceptionInterruptedException
-
run
public void run()TheCharBucketloading process that executes in parallel until the input is completely read. Once the end of the input is reached, theReaderinstance 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 theCharBucketloading process and closes the reader provided in the constructor of this class -
reportError
void reportError()
-