java.util.concurrent.CountedCompleter Java Examples

The following examples show how to use java.util.concurrent.CountedCompleter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArraysParallelSortHelpers.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    double[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #2
Source File: ArraysParallelSortHelpers.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    Comparator<? super T> c = this.comparator;
    T[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger<>(s, w, a, wb, h,
                                          wb+h, n-h, b, g, c));
        Relay rc = new Relay(new Merger<>(fc, a, w, b+h, q,
                                          b+u, n-u, wb+h, g, c));
        new Sorter<>(rc, a, w, b+u, n-u, wb+u, g, c).fork();
        new Sorter<>(rc, a, w, b+h, q, wb+h, g, c).fork();
        Relay bc = new Relay(new Merger<>(fc, a, w, b, q,
                                          b+q, h-q, wb, g, c));
        new Sorter<>(bc, a, w, b+q, h-q, wb+q, g, c).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    TimSort.sort(a, b, b + n, c, w, wb, n);
    s.tryComplete();
}
 
Example #3
Source File: ArraysParallelSortHelpers.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    double[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #4
Source File: ArraysParallelSortHelpers.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    short[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #5
Source File: ArraysParallelSortHelpers.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    short[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #6
Source File: ForEachOps.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onCompletion(CountedCompleter<?> caller) {
    if (node != null) {
        // Dump buffered elements from this leaf into the sink
        node.forEach(action);
        node = null;
    }
    else if (spliterator != null) {
        // Dump elements output from this leaf's pipeline into the sink
        helper.wrapAndCopyInto(action, spliterator);
        spliterator = null;
    }

    // The completion of this task *and* the dumping of elements
    // "happens-before" completion of the associated left-most leaf task
    // of right subtree (if any, which can be this task's right sibling)
    //
    ForEachOrderedTask<S, T> leftDescendant = completionMap.remove(this);
    if (leftDescendant != null)
        leftDescendant.tryComplete();
}
 
Example #7
Source File: ArraysParallelSortHelpers.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    int[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #8
Source File: ArraysParallelSortHelpers.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    long[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #9
Source File: ArraysParallelSortHelpers.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    int[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #10
Source File: ArraysParallelSortHelpers.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    Comparator<? super T> c = this.comparator;
    T[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger<T>(s, w, a, wb, h,
                                           wb+h, n-h, b, g, c));
        Relay rc = new Relay(new Merger<T>(fc, a, w, b+h, q,
                                           b+u, n-u, wb+h, g, c));
        new Sorter<T>(rc, a, w, b+u, n-u, wb+u, g, c).fork();
        new Sorter<T>(rc, a, w, b+h, q, wb+h, g, c).fork();;
        Relay bc = new Relay(new Merger<T>(fc, a, w, b, q,
                                           b+q, h-q, wb, g, c));
        new Sorter<T>(bc, a, w, b+q, h-q, wb+q, g, c).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    TimSort.sort(a, b, b + n, c, w, wb, n);
    s.tryComplete();
}
 
Example #11
Source File: ArraysParallelSortHelpers.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    long[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #12
Source File: ArraysParallelSortHelpers.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    float[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #13
Source File: ArraysParallelSortHelpers.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    int[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #14
Source File: WhileOps.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public final void onCompletion(CountedCompleter<?> caller) {
    if (!isLeaf()) {
        Node<P_OUT> result;
        shortCircuited = leftChild.shortCircuited | rightChild.shortCircuited;
        if (isOrdered && canceled) {
            thisNodeSize = 0;
            result = getEmptyResult();
        }
        else if (isOrdered && leftChild.shortCircuited) {
            // If taking finished on the left node then
            // use the left node result
            thisNodeSize = leftChild.thisNodeSize;
            result = leftChild.getLocalResult();
        }
        else {
            thisNodeSize = leftChild.thisNodeSize + rightChild.thisNodeSize;
            result = merge();
        }

        setLocalResult(result);
    }

    completed = true;
    super.onCompletion(caller);
}
 
Example #15
Source File: ArraysParallelSortHelpers.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    long[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #16
Source File: ForEachOps.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public void onCompletion(CountedCompleter<?> caller) {
    if (node != null) {
        // Dump buffered elements from this leaf into the sink
        node.forEach(action);
        node = null;
    }
    else if (spliterator != null) {
        // Dump elements output from this leaf's pipeline into the sink
        helper.wrapAndCopyInto(action, spliterator);
        spliterator = null;
    }

    // The completion of this task *and* the dumping of elements
    // "happens-before" completion of the associated left-most leaf task
    // of right subtree (if any, which can be this task's right sibling)
    //
    ForEachOrderedTask<S, T> leftDescendant = completionMap.remove(this);
    if (leftDescendant != null)
        leftDescendant.tryComplete();
}
 
Example #17
Source File: ArraysParallelSortHelpers.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    short[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #18
Source File: ArraysParallelSortHelpers.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    float[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger(s, w, a, wb, h,
                                        wb+h, n-h, b, g));
        Relay rc = new Relay(new Merger(fc, a, w, b+h, q,
                                        b+u, n-u, wb+h, g));
        new Sorter(rc, a, w, b+u, n-u, wb+u, g).fork();
        new Sorter(rc, a, w, b+h, q, wb+h, g).fork();;
        Relay bc = new Relay(new Merger(fc, a, w, b, q,
                                        b+q, h-q, wb, g));
        new Sorter(bc, a, w, b+q, h-q, wb+q, g).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    DualPivotQuicksort.sort(a, b, b + n - 1, w, wb, n);
    s.tryComplete();
}
 
Example #19
Source File: ArraysParallelSortHelpers.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public final void compute() {
    CountedCompleter<?> s = this;
    Comparator<? super T> c = this.comparator;
    T[] a = this.a, w = this.w; // localize all params
    int b = this.base, n = this.size, wb = this.wbase, g = this.gran;
    while (n > g) {
        int h = n >>> 1, q = h >>> 1, u = h + q; // quartiles
        Relay fc = new Relay(new Merger<T>(s, w, a, wb, h,
                                           wb+h, n-h, b, g, c));
        Relay rc = new Relay(new Merger<T>(fc, a, w, b+h, q,
                                           b+u, n-u, wb+h, g, c));
        new Sorter<T>(rc, a, w, b+u, n-u, wb+u, g, c).fork();
        new Sorter<T>(rc, a, w, b+h, q, wb+h, g, c).fork();;
        Relay bc = new Relay(new Merger<T>(fc, a, w, b, q,
                                           b+q, h-q, wb, g, c));
        new Sorter<T>(bc, a, w, b+q, h-q, wb+q, g, c).fork();
        s = new EmptyCompleter(bc);
        n = q;
    }
    TimSort.sort(a, b, b + n, c, w, wb, n);
    s.tryComplete();
}
 
Example #20
Source File: ArraysParallelSortHelpers.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
Merger(CountedCompleter<?> par, T[] a, T[] w,
       int lbase, int lsize, int rbase,
       int rsize, int wbase, int gran,
       Comparator<? super T> comparator) {
    super(par);
    this.a = a; this.w = w;
    this.lbase = lbase; this.lsize = lsize;
    this.rbase = rbase; this.rsize = rsize;
    this.wbase = wbase; this.gran = gran;
    this.comparator = comparator;
}
 
Example #21
Source File: ForkJoinPool8Test.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public final void onCompletion(CountedCompleter caller) {
    FailingCCF p = (FailingCCF)getCompleter();
    int n = number + rnumber;
    if (p != null)
        p.number = n;
    else
        number = n;
}
 
Example #22
Source File: ArraysParallelSortHelpers.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
Merger(CountedCompleter<?> par, short[] a, short[] w,
       int lbase, int lsize, int rbase,
       int rsize, int wbase, int gran) {
    super(par);
    this.a = a; this.w = w;
    this.lbase = lbase; this.lsize = lsize;
    this.rbase = rbase; this.rsize = rsize;
    this.wbase = wbase; this.gran = gran;
}
 
Example #23
Source File: FindOps.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCompletion(CountedCompleter<?> caller) {
    if (op.mustFindFirst) {
            for (FindTask<P_IN, P_OUT, O> child = leftChild, p = null; child != p;
                 p = child, child = rightChild) {
            O result = child.getLocalResult();
            if (result != null && op.presentPredicate.test(result)) {
                setLocalResult(result);
                foundResult(result);
                break;
            }
        }
    }
    super.onCompletion(caller);
}
 
Example #24
Source File: ReduceOps.java    From desugar_jdk_libs with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCompletion(CountedCompleter<?> caller) {
    if (!isLeaf()) {
        S leftResult = leftChild.getLocalResult();
        leftResult.combine(rightChild.getLocalResult());
        setLocalResult(leftResult);
    }
    // GC spliterator, left and right child
    super.onCompletion(caller);
}
 
Example #25
Source File: ForkJoinPool8Test.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public final void onCompletion(CountedCompleter caller) {
    FailingCCF p = (FailingCCF)getCompleter();
    int n = number + rnumber;
    if (p != null)
        p.number = n;
    else
        number = n;
}
 
Example #26
Source File: SliceOps.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onCompletion(CountedCompleter<?> caller) {
    if (!isLeaf()) {
        Node<P_OUT> result;
        thisNodeSize = leftChild.thisNodeSize + rightChild.thisNodeSize;
        if (canceled) {
            thisNodeSize = 0;
            result = getEmptyResult();
        }
        else if (thisNodeSize == 0)
            result = getEmptyResult();
        else if (leftChild.thisNodeSize == 0)
            result = rightChild.getLocalResult();
        else {
            result = Nodes.conc(op.getOutputShape(),
                                leftChild.getLocalResult(), rightChild.getLocalResult());
        }
        setLocalResult(isRoot() ? doTruncate(result) : result);
        completed = true;
    }
    if (targetSize >= 0
        && !isRoot()
        && isLeftCompleted(targetOffset + targetSize))
            cancelLaterNodes();

    super.onCompletion(caller);
}
 
Example #27
Source File: ArraysParallelSortHelpers.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
Merger(CountedCompleter<?> par, T[] a, T[] w,
       int lbase, int lsize, int rbase,
       int rsize, int wbase, int gran,
       Comparator<? super T> comparator) {
    super(par);
    this.a = a; this.w = w;
    this.lbase = lbase; this.lsize = lsize;
    this.rbase = rbase; this.rsize = rsize;
    this.wbase = wbase; this.gran = gran;
    this.comparator = comparator;
}
 
Example #28
Source File: ArraysParallelSortHelpers.java    From j2objc with Apache License 2.0 5 votes vote down vote up
Merger(CountedCompleter<?> par, char[] a, char[] w,
       int lbase, int lsize, int rbase,
       int rsize, int wbase, int gran) {
    super(par);
    this.a = a; this.w = w;
    this.lbase = lbase; this.lsize = lsize;
    this.rbase = rbase; this.rsize = rsize;
    this.wbase = wbase; this.gran = gran;
}
 
Example #29
Source File: ArraysParallelSortHelpers.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
Merger(CountedCompleter<?> par, byte[] a, byte[] w,
       int lbase, int lsize, int rbase,
       int rsize, int wbase, int gran) {
    super(par);
    this.a = a; this.w = w;
    this.lbase = lbase; this.lsize = lsize;
    this.rbase = rbase; this.rsize = rsize;
    this.wbase = wbase; this.gran = gran;
}
 
Example #30
Source File: FindOps.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCompletion(CountedCompleter<?> caller) {
    if (op.mustFindFirst) {
            for (FindTask<P_IN, P_OUT, O> child = leftChild, p = null; child != p;
                 p = child, child = rightChild) {
            O result = child.getLocalResult();
            if (result != null && op.presentPredicate.test(result)) {
                setLocalResult(result);
                foundResult(result);
                break;
            }
        }
    }
    super.onCompletion(caller);
}