Top Description Fields Constructors Methods
com.univocity.parsers.common.input.concurrent

pack-priv Class ConcurrentCharLoader

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
com.univocity.parsers.common.*, com.univocity.parsers.common.input.*, java.io.*, java.util.concurrent.*

A concurrent character loader for loading a pool of CharBucket instances using a java.io.Reader in a separate thread
Author
Univocity Software Pty Ltd - [email protected]
See Also
ConcurrentCharInputReader, CharBucket, Entry

Field Summary

Modifier and TypeField and Description
private boolean
private Thread
private final ArrayBlockingQueue<Object>
private final boolean
private Entry<CharBucket>
private final CharBucket
private Exception
private boolean
private final FixedInstancePool<CharBucket>
pack-priv Reader

Constructor Summary

AccessConstructor and Description
public
ConcurrentCharLoader(Reader
The source of characters to extract and fill CharBucket instances
reader
,
final int
The size of each individual CharBucket
bucketSize
,
int
The number of CharBucket instances used to extract characters from the given reader.
bucketQuantity
,
boolean
Indicates whether to automatically close the input when stopReading() is called
closeOnStop
)

Creates a FixedInstancePool with a given amount of CharBucket instances and starts a thread to fill each one.

Method Summary

Modifier and TypeMethod and Description
public synchronized CharBucket

Returns:

the next available bucket.
nextBucket
()

Returns the next available bucket.

private int
pack-priv void
public void
run()

Implements java.lang.Runnable.run.

The CharBucket loading process that executes in parallel until the input is completely read.
private void
public void
stopReading()

Stops the CharBucket loading process and closes the reader provided in the constructor of this class

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeback to summary
private boolean active
activeExecutionback to summary
private Thread activeExecution
bucketsback to summary
private final ArrayBlockingQueue<Object> buckets
closeOnStopback to summary
private final boolean closeOnStop
currentBucketback to summary
private Entry<CharBucket> currentBucket
endback to summary
private final CharBucket end
errorback to summary
private Exception error
finishedback to summary
private boolean finished
instancesback to summary
private final FixedInstancePool<CharBucket> instances
readerback to summary
pack-priv Reader reader

Constructor Detail

ConcurrentCharLoaderback to summary
public ConcurrentCharLoader(Reader reader, final int bucketSize, int bucketQuantity, boolean closeOnStop)

Creates a FixedInstancePool with a given amount of CharBucket instances and starts a thread to fill each one.

Parameters
reader:Reader

The source of characters to extract and fill CharBucket instances

bucketSize:int

The size of each individual CharBucket

bucketQuantity:int

The number of CharBucket instances used to extract characters from the given reader.

closeOnStop:boolean

Indicates whether to automatically close the input when stopReading() is called

Method Detail

nextBucketback to summary
public synchronized CharBucket nextBucket()

Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.

Returns:CharBucket

the next available bucket.

Annotations
@SuppressWarnings:unchecked
readBucketback to summary
private int readBucket() throws IOException, InterruptedException
reportErrorback to summary
pack-priv void reportError()
runback to summary
public void run()

Implements java.lang.Runnable.run.

The CharBucket loading process that executes in parallel until the input is completely read. Once the end of the input is reached, the java.io.Reader instance provided in the constructor is closed.

Annotations
@Override
setErrorback to summary
private void setError(Exception e)
stopReadingback to summary
public void stopReading()

Stops the CharBucket loading process and closes the reader provided in the constructor of this class