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 Project: hottub   Author: dsrg-uoft   File: ArraysParallelSortHelpers.java    License: 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 #2
Source Project: Bytecoder   Author: mirkosertic   File: ForEachOps.java    License: 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 #3
Source Project: Bytecoder   Author: mirkosertic   File: WhileOps.java    License: 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 #4
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: ArraysParallelSortHelpers.java    License: 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 #5
Source Project: jdk8u60   Author: chenghanpeng   File: ArraysParallelSortHelpers.java    License: 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 #6
Source Project: TencentKona-8   Author: Tencent   File: ArraysParallelSortHelpers.java    License: 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 #7
Source Project: Bytecoder   Author: mirkosertic   File: ArraysParallelSortHelpers.java    License: 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 #8
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: ArraysParallelSortHelpers.java    License: 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 #9
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ArraysParallelSortHelpers.java    License: 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 #10
Source Project: jdk8u-jdk   Author: frohoff   File: ArraysParallelSortHelpers.java    License: 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 #11
Source Project: hottub   Author: dsrg-uoft   File: ArraysParallelSortHelpers.java    License: 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 #12
Source Project: jdk8u-dev-jdk   Author: frohoff   File: ArraysParallelSortHelpers.java    License: 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 #13
Source Project: Java8CN   Author: Java8-CNAPI-Team   File: ArraysParallelSortHelpers.java    License: 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 #14
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ForEachOps.java    License: 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 #15
Source Project: dragonwell8_jdk   Author: alibaba   File: ArraysParallelSortHelpers.java    License: 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 #16
Source Project: dragonwell8_jdk   Author: alibaba   File: ArraysParallelSortHelpers.java    License: 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 #17
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: ArraysParallelSortHelpers.java    License: 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 #18
Source Project: jdk8u-jdk   Author: frohoff   File: ArraysParallelSortHelpers.java    License: 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 #19
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: ArraysParallelSortHelpers.java    License: 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 #20
Source Project: openjdk-8   Author: bpupadhyaya   File: SliceOps.java    License: 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 #21
Source Project: jdk8u-jdk   Author: frohoff   File: FindOps.java    License: 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 #22
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: ReduceOps.java    License: Apache License 2.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 #23
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ForkJoinPool8Test.java    License: GNU General Public License v2.0 5 votes vote down vote up
public final void onCompletion(CountedCompleter caller) {
    CCF p = (CCF)getCompleter();
    int n = number + rnumber;
    if (p != null)
        p.rnumber = n;
    else
        number = n;
}
 
Example #24
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: ArraysParallelSortHelpers.java    License: Apache License 2.0 5 votes vote down vote up
Sorter(CountedCompleter<?> par, T[] a, T[] w, int base, int size,
       int wbase, int gran,
       Comparator<? super T> comparator) {
    super(par);
    this.a = a; this.w = w; this.base = base; this.size = size;
    this.wbase = wbase; this.gran = gran;
    this.comparator = comparator;
}
 
Example #25
Source Project: jdk8u-dev-jdk   Author: frohoff   File: ArraysParallelSortHelpers.java    License: GNU General Public License v2.0 5 votes vote down vote up
Merger(CountedCompleter<?> par, int[] a, int[] 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 #26
Source Project: j2objc   Author: google   File: CountedCompleterTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * getCompleter returns parent or null if at root
 */
public void testGetCompleter() {
    NoopCC a = new NoopCC();
    assertNull(a.getCompleter());
    CountedCompleter b = new NoopCC(a);
    assertSame(a, b.getCompleter());
    CountedCompleter c = new NoopCC(b);
    assertSame(b, c.getCompleter());
}
 
Example #27
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ArraysParallelSortHelpers.java    License: 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 #28
Source Project: j2objc   Author: google   File: SliceOps.java    License: Apache License 2.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 #29
Source Project: Java8CN   Author: Java8-CNAPI-Team   File: ArraysParallelSortHelpers.java    License: Apache License 2.0 5 votes vote down vote up
Merger(CountedCompleter<?> par, float[] a, float[] 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 Project: j2objc   Author: google   File: CountedCompleterTest.java    License: Apache License 2.0 5 votes vote down vote up
public final void onCompletion(CountedCompleter caller) {
    super.onCompletion(caller);
    CCF p = (CCF)getCompleter();
    int n = number + rnumber;
    if (p != null)
        p.number = n;
    else
        number = n;
}