java.lang.Object
java.io.Reader
org.simpleflatmapper.util.ParallelReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionParallelReader(Reader reader) Create a new ParallelReader that will fetch the data from that reader in a another thread.ParallelReader(Reader reader, Executor executorService) ParallelReader(Reader reader, Executor executorService, int bufferSize) ParallelReader(Reader reader, Executor executorService, int bufferSize, int readBufferSize) ParallelReader(Reader reader, Executor executorService, int bufferSize, int readBufferSize, ParallelReader.WaitingStrategy waitingStrategy) Create a new ParallelReader. -
Method Summary
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Constructor Details
-
ParallelReader
Create a new ParallelReader that will fetch the data from that reader in a another thread. By default it will use the ForkJoinPool common pool from java8 or a ExecutorService with a pool size set to the number of available cores. If the number of cores is 1 it will create a new Thread everytime. The default WaitingStrategy just call LockSupport.parkNanos(1l);- Parameters:
reader- the reader
-
ParallelReader
-
ParallelReader
-
ParallelReader
-
ParallelReader
public ParallelReader(Reader reader, Executor executorService, int bufferSize, int readBufferSize, ParallelReader.WaitingStrategy waitingStrategy) Create a new ParallelReader.- Parameters:
reader- the readerexecutorService- the executor to fetch frombufferSize- the size of the ring bufferreadBufferSize- the size of the buffer to fetch datawaitingStrategy- the waiting strategy when the ring buffer is full
-
-
Method Details
-
getDefaultExecutor
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin classReader- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-