/** * @param reader Unique DataReader. If null, empty batches will be generated * @param tasks Generated Tasks. Each task will be used in one thread. Will use tasks.size() as "numTasks". * @param writer Unique DataWriter. If null, data generated by the task will be lost. * @param config configuration. * @throws IllegalArgumentException Exception. */ public ParallelTaskRunner(DataReader<I> reader, List<? extends org.opencb.commons.run.Task<I, O>> tasks, DataWriter<O> writer, Config config) { this.config = config; this.reader = reader; this.writer = writer; this.tasks = new ArrayList<>(tasks); check(); }
/** * @param reader Unique DataReader. If null, empty batches will be generated * @param task Task to be used. Will be used the same instance in all threads * @param writer Unique DataWriter. If null, data generated by the task will be lost. * @param config configuration. * @throws IllegalArgumentException Exception. */ public ParallelTaskRunner(DataReader<I> reader, org.opencb.commons.run.Task<I, O> task, DataWriter<O> writer, Config config) { this.config = config; this.reader = reader; this.writer = writer; this.tasks = new ArrayList<>(config.numTasks); for (int i = 0; i < config.numTasks; i++) { tasks.add(task); } check(); }
/** * @param reader Unique DataReader. If null, empty batches will be generated. * @param taskSupplier TaskGenerator. Will generate a new task for each thread. * @param writer Unique DataWriter. If null, data generated by the task will be lost. * @param config configuration. * @throws IllegalArgumentException Exception. */ public ParallelTaskRunner(DataReader<I> reader, Supplier<? extends org.opencb.commons.run.Task<I, O>> taskSupplier, DataWriter<O> writer, Config config) { this.config = config; this.reader = reader; this.writer = writer; this.tasks = new ArrayList<>(config.numTasks); for (int i = 0; i < config.numTasks; i++) { tasks.add(taskSupplier.get()); } check(); }