--- jsr166/src/main/java/util/ArrayPrefixHelpers.java 2013/01/16 19:01:22 1.1 +++ jsr166/src/main/java/util/ArrayPrefixHelpers.java 2015/09/19 18:36:55 1.5 @@ -5,12 +5,13 @@ */ package java.util; -import java.util.concurrent.ForkJoinPool; + import java.util.concurrent.CountedCompleter; +import java.util.concurrent.ForkJoinPool; import java.util.function.BinaryOperator; +import java.util.function.DoubleBinaryOperator; import java.util.function.IntBinaryOperator; import java.util.function.LongBinaryOperator; -import java.util.function.DoubleBinaryOperator; /** * ForkJoin tasks to perform Arrays.parallelPrefix operations. @@ -19,7 +20,7 @@ import java.util.function.DoubleBinaryOp * @since 1.8 */ class ArrayPrefixHelpers { - private ArrayPrefixHelpers() {}; // non-instantiable + private ArrayPrefixHelpers() {} // non-instantiable /* * Parallel prefix (aka cumulate, scan) task classes @@ -79,20 +80,6 @@ class ArrayPrefixHelpers { T in, out; final int lo, hi, origin, fence, threshold; - /** Root task constructor */ - public CumulateTask(CumulateTask parent, - BinaryOperator function, - T[] array, int lo, int hi) { - super(parent); - this.function = function; this.array = array; - this.lo = this.origin = lo; this.hi = this.fence = hi; - int p; - this.threshold = - (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) - <= MIN_PARTITION ? MIN_PARTITION : p; - } - - /** Subtask constructor */ CumulateTask(CumulateTask parent, BinaryOperator function, T[] array, int origin, int fence, int threshold, int lo, int hi) { @@ -187,7 +174,9 @@ class ArrayPrefixHelpers { sum = t.in; t.out = sum; for (CumulateTask par;;) { // propagate - if ((par = (CumulateTask)t.getCompleter()) == null) { + @SuppressWarnings("unchecked") CumulateTask partmp + = (CumulateTask)t.getCompleter(); + if ((par = partmp) == null) { if ((state & FINISHED) != 0) // enable join t.quietlyComplete(); break outer; @@ -229,20 +218,6 @@ class ArrayPrefixHelpers { long in, out; final int lo, hi, origin, fence, threshold; - /** Root task constructor */ - public LongCumulateTask(LongCumulateTask parent, - LongBinaryOperator function, - long[] array, int lo, int hi) { - super(parent); - this.function = function; this.array = array; - this.lo = this.origin = lo; this.hi = this.fence = hi; - int p; - this.threshold = - (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) - <= MIN_PARTITION ? MIN_PARTITION : p; - } - - /** Subtask constructor */ LongCumulateTask(LongCumulateTask parent, LongBinaryOperator function, long[] array, int origin, int fence, int threshold, int lo, int hi) { @@ -379,23 +354,9 @@ class ArrayPrefixHelpers { double in, out; final int lo, hi, origin, fence, threshold; - /** Root task constructor */ - public DoubleCumulateTask(DoubleCumulateTask parent, - DoubleBinaryOperator function, - double[] array, int lo, int hi) { - super(parent); - this.function = function; this.array = array; - this.lo = this.origin = lo; this.hi = this.fence = hi; - int p; - this.threshold = - (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) - <= MIN_PARTITION ? MIN_PARTITION : p; - } - - /** Subtask constructor */ DoubleCumulateTask(DoubleCumulateTask parent, DoubleBinaryOperator function, - double[] array, int origin, int fence, int threshold, - int lo, int hi) { + double[] array, int origin, int fence, int threshold, + int lo, int hi) { super(parent); this.function = function; this.array = array; this.origin = origin; this.fence = fence; @@ -529,23 +490,9 @@ class ArrayPrefixHelpers { int in, out; final int lo, hi, origin, fence, threshold; - /** Root task constructor */ - public IntCumulateTask(IntCumulateTask parent, - IntBinaryOperator function, - int[] array, int lo, int hi) { - super(parent); - this.function = function; this.array = array; - this.lo = this.origin = lo; this.hi = this.fence = hi; - int p; - this.threshold = - (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) - <= MIN_PARTITION ? MIN_PARTITION : p; - } - - /** Subtask constructor */ IntCumulateTask(IntCumulateTask parent, IntBinaryOperator function, - int[] array, int origin, int fence, int threshold, - int lo, int hi) { + int[] array, int origin, int fence, int threshold, + int lo, int hi) { super(parent); this.function = function; this.array = array; this.origin = origin; this.fence = fence;