Java Code Examples for java.util.concurrent.ForkJoinPool#getCommonPoolParallelism()

The following examples show how to use java.util.concurrent.ForkJoinPool#getCommonPoolParallelism() . 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: ArrayPrefixHelpers.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/** Root task constructor */
public CumulateTask(CumulateTask<T> parent,
                    BinaryOperator<T> 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;
}
 
Example 2
Source File: CompletableFuture.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Starts the given async task using the given executor, unless
 * the executor is ForkJoinPool.commonPool and it has been
 * disabled, in which case starts a new thread.
 */
static void execAsync(Executor e, Async r) {
    if (e == ForkJoinPool.commonPool() &&
        ForkJoinPool.getCommonPoolParallelism() <= 1)
        new Thread(r).start();
    else
        e.execute(r);
}
 
Example 3
Source File: ArrayPrefixHelpers.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** 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;
}
 
Example 4
Source File: CompletableFutureTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * defaultExecutor by default returns the commonPool if
 * it supports more than one thread.
 */
public void testDefaultExecutor() {
    CompletableFuture<Integer> f = new CompletableFuture<>();
    Executor e = f.defaultExecutor();
    Executor c = ForkJoinPool.commonPool();
    if (ForkJoinPool.getCommonPoolParallelism() > 1)
        assertSame(e, c);
    else
        assertNotSame(e, c);
}
 
Example 5
Source File: ArrayPrefixHelpers.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** 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;
}
 
Example 6
Source File: ArrayPrefixHelpers.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** 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;
}
 
Example 7
Source File: PrimeNumbersUnitManualTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenNewWorkStealingPool_whenGettingPrimes_thenStealCountChanges() {
    StringBuilder info = new StringBuilder();

    for (int granularity : PrimeNumbers.GRANULARITIES) {
        int parallelism = ForkJoinPool.getCommonPoolParallelism();
        ForkJoinPool pool =
          (ForkJoinPool) Executors.newWorkStealingPool(parallelism);

        stealCountInfo(info, granularity, pool);
    }
    logger.info("\nExecutors.newWorkStealingPool ->" + info.toString());
}
 
Example 8
Source File: ArrayPrefixHelpers.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example 9
Source File: ArrayPrefixHelpers.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Root task constructor */
public CumulateTask(CumulateTask<T> parent,
                    BinaryOperator<T> 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;
}
 
Example 10
Source File: ArrayPrefixHelpers.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** 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;
}
 
Example 11
Source File: ArrayPrefixHelpers.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example 12
Source File: ArrayPrefixHelpers.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** 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;
}
 
Example 13
Source File: ArrayPrefixHelpers.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** 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;
}
 
Example 14
Source File: ArrayPrefixHelpers.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/** Root task constructor */
public CumulateTask(CumulateTask<T> parent,
                    BinaryOperator<T> 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;
}
 
Example 15
Source File: ArrayPrefixHelpers.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/** Root task constructor */
public CumulateTask(CumulateTask<T> parent,
                    BinaryOperator<T> 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;
}
 
Example 16
Source File: ArrayPrefixHelpers.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example 17
Source File: ArrayPrefixHelpers.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example 18
Source File: ArrayPrefixHelpers.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** Root task constructor */
public CumulateTask(CumulateTask<T> parent,
                    BinaryOperator<T> 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;
}
 
Example 19
Source File: ArrayPrefixHelpers.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/** 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;
}
 
Example 20
Source File: BufferParallelAggregation.java    From RoaringBitmap with Apache License 2.0 4 votes vote down vote up
private static int availableParallelism() {
  return ForkJoinTask.inForkJoinPool()
          ? ForkJoinTask.getPool().getParallelism()
          : ForkJoinPool.getCommonPoolParallelism();
}