Class ConcurrentCharLoader

java.lang.Object
com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader
All Implemented Interfaces:
Runnable

class ConcurrentCharLoader extends Object implements Runnable
A concurrent character loader for loading a pool of CharBucket instances using a Reader in a separate thread
See Also:
  • Field Details

  • Constructor Details

    • ConcurrentCharLoader

      public ConcurrentCharLoader(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.
      Parameters:
      reader - The source of characters to extract and fill CharBucket instances
      bucketSize - The size of each individual CharBucket
      bucketQuantity - The number of CharBucket instances used to extract characters from the given reader.
      closeOnStop - Indicates whether to automatically close the input when stopReading() is called
  • Method Details

    • readBucket

      private int readBucket() throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • run

      public void run()
      The 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.
      Specified by:
      run in interface Runnable
    • setError

      private void setError(Exception e)
    • nextBucket

      public CharBucket 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 the CharBucket loading process and closes the reader provided in the constructor of this class
    • reportError

      void reportError()