public void executeAndCombine(Executor executor, ProcedureFactory<BT> procedureFactory, T[] array) { this.createAndExecuteTasks(executor, procedureFactory, array); this.join(); if (this.error != null) { throw new RuntimeException("One or more parallel tasks failed", this.error); } //don't combine until the lock is notified this.combineTasks(); }
@Override public void run() { try { this.procedure = this.procedureFactory.create(); ArrayIterate.forEach(this.array, this.start, this.end - 1, this.procedure); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } }
public static <T, BT extends Procedure<? super T>> void forEachOn( T[] array, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, Executor executor) { if (ArrayIterate.notEmpty(array)) { int size = array.length; if (size < minForkSize) { BT procedure = procedureFactory.create(); ArrayIterate.forEach(array, procedure); ParallelArrayIterate.combineSingleProcedure(combiner, procedure); } else { int threadCount = Math.min(size, taskCount); new ArrayProcedureFJTaskRunner<>(combiner, threadCount).executeAndCombine(executor, procedureFactory, array); } } }
public static <T, BT extends Procedure<? super T>> void forEachOn( T[] array, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, Executor executor) { if (ArrayIterate.notEmpty(array)) { int size = array.length; if (size < minForkSize) { BT procedure = procedureFactory.create(); ArrayIterate.forEach(array, procedure); ParallelArrayIterate.combineSingleProcedure(combiner, procedure); } else { int threadCount = Math.min(size, taskCount); new ArrayProcedureFJTaskRunner<>(combiner, threadCount).executeAndCombine(executor, procedureFactory, array); } } }
public void executeAndCombine(Executor executor, ProcedureFactory<BT> procedureFactory, T[] array) { this.createAndExecuteTasks(executor, procedureFactory, array); this.join(); if (this.error != null) { throw new RuntimeException("One or more parallel tasks failed", this.error); } //don't combine until the lock is notified this.combineTasks(); }
@Override public void run() { try { this.procedure = this.procedureFactory.create(); ArrayIterate.forEach(this.array, this.start, this.end - 1, this.procedure); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } }
public static <T, BT extends Procedure<? super T>> void forEachOn( T[] array, ProcedureFactory<BT> procedureFactory, Combiner<BT> combiner, int minForkSize, int taskCount, Executor executor) { if (ArrayIterate.notEmpty(array)) { int size = array.length; if (size < minForkSize) { BT procedure = procedureFactory.create(); ArrayIterate.forEach(array, procedure); ParallelArrayIterate.combineSingleProcedure(combiner, procedure); } else { int threadCount = Math.min(size, taskCount); new ArrayProcedureFJTaskRunner<>(combiner, threadCount).executeAndCombine(executor, procedureFactory, array); } } }
public void executeAndCombine(Executor executor, ProcedureFactory<BT> procedureFactory, T[] array) { this.createAndExecuteTasks(executor, procedureFactory, array); this.join(); if (this.error != null) { throw new RuntimeException("One or more parallel tasks failed", this.error); } //don't combine until the lock is notified this.combineTasks(); }
@Override public void run() { try { this.procedure = this.procedureFactory.create(); ArrayIterate.forEach(this.array, this.start, this.end - 1, this.procedure); } catch (Throwable newError) { this.taskRunner.setFailed(newError); } finally { this.taskRunner.taskCompleted(this); } }