java.util.concurrent.ForkJoinPool.getCommonPoolParallelism()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中java.util.concurrent.ForkJoinPool.getCommonPoolParallelism()方法的一些代码示例,展示了ForkJoinPool.getCommonPoolParallelism()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ForkJoinPool.getCommonPoolParallelism()方法的具体详情如下:
包路径:java.util.concurrent.ForkJoinPool
类名称:ForkJoinPool
方法名:getCommonPoolParallelism

ForkJoinPool.getCommonPoolParallelism介绍

[英]Returns the targeted parallelism level of the common pool.
[中]返回公共池的目标并行级别。

代码示例

代码示例来源:origin: orbit/orbit

public WaitFreeMultiExecutionSerializer()
{
  this(ExecutorUtils.newScalingThreadPool(ForkJoinPool.getCommonPoolParallelism()));
}

代码示例来源:origin: ehcache/ehcache3

/**
 * Computes initial batch value for bulk tasks. The returned value
 * is approximately exp2 of the number of times (minus one) to
 * split task by two before executing leaf action. This value is
 * faster to compute and more convenient to use as a guide to
 * splitting than is the depth, since it is used while dividing by
 * two anyway.
 */
final int batchFor(long b) {
  long n;
  if (b == Long.MAX_VALUE || (n = sumCount()) <= 1L || n < b)
    return 0;
  int sp = ForkJoinPool.getCommonPoolParallelism() << 2; // slack of 4
  return (b <= 0L || (n /= b) >= sp) ? sp : (int)n;
}

代码示例来源:origin: RoaringBitmap/RoaringBitmap

private static int availableParallelism() {
 return ForkJoinTask.inForkJoinPool()
     ? ForkJoinTask.getPool().getParallelism()
     : ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: RoaringBitmap/RoaringBitmap

private static int availableParallelism() {
 return ForkJoinTask.inForkJoinPool()
     ? ForkJoinTask.getPool().getParallelism()
     : ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: biezhi/learn-java8

public static void main(String[] args) {
    System.out.println("Parallelism: " + ForkJoinPool.getCommonPoolParallelism());

    testForEach();
//        testSearch();
//        testReduce();
  }

代码示例来源:origin: stackoverflow.com

private static final int getSplitThreshold(int n) {
 int p = ForkJoinPool.getCommonPoolParallelism();
 int t = (p > 1) ? (1 + n / (p << 3)) : n;
 return t < MIN_ARRAY_SORT_GRAN ? MIN_ARRAY_SORT_GRAN : t;
}

代码示例来源:origin: stackoverflow.com

/**
 * Default target factor of leaf tasks for parallel decomposition.
 * To allow load balancing, we over-partition, currently to approximately
 * four tasks per processor, which enables others to help out
 * if leaf tasks are uneven or some processors are otherwise busy.
 */
static final int LEAF_TARGET = ForkJoinPool.getCommonPoolParallelism() << 2;

代码示例来源:origin: weld/core

@Override
protected int getThreadPoolSize() {
  return ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: weld/core

@Override
protected int getThreadPoolSize() {
  return ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: weld/core

@Override
protected int getThreadPoolSize() {
  return ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

@Override
protected int getThreadPoolSize() {
  return ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded

@Override
protected int getThreadPoolSize() {
  return ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: coffeewar/enode-master

@Override
public int getCommonPoolParallelism() {
  return java.util.concurrent.ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: neo4j-contrib/neo4j-graph-algorithms

public static ForkJoinPool createFJPool() {
  return new ForkJoinPool(ForkJoinPool.getCommonPoolParallelism());
}

代码示例来源:origin: org.neo4j/graph-algorithms-core

public static ForkJoinPool createFJPool() {
  return new ForkJoinPool(ForkJoinPool.getCommonPoolParallelism());
}

代码示例来源:origin: org.ehcache/ehcache

/**
 * Computes initial batch value for bulk tasks. The returned value
 * is approximately exp2 of the number of times (minus one) to
 * split task by two before executing leaf action. This value is
 * faster to compute and more convenient to use as a guide to
 * splitting than is the depth, since it is used while dividing by
 * two anyway.
 */
final int batchFor(long b) {
  long n;
  if (b == Long.MAX_VALUE || (n = sumCount()) <= 1L || n < b)
    return 0;
  int sp = ForkJoinPool.getCommonPoolParallelism() << 2; // slack of 4
  return (b <= 0L || (n /= b) >= sp) ? sp : (int)n;
}

代码示例来源:origin: dunwu/javacore

public static void main(String[] args) {
  System.out.println("Parallelism: " + ForkJoinPool.getCommonPoolParallelism());
  testForEach();
  testSearch();
  testReduce();
}

代码示例来源:origin: org.roaringbitmap/RoaringBitmap

private static int availableParallelism() {
 return ForkJoinTask.inForkJoinPool()
     ? ForkJoinTask.getPool().getParallelism()
     : ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: org.roaringbitmap/RoaringBitmap

private static int availableParallelism() {
 return ForkJoinTask.inForkJoinPool()
     ? ForkJoinTask.getPool().getParallelism()
     : ForkJoinPool.getCommonPoolParallelism();
}

代码示例来源:origin: eventsourcing/es4j

@DataProvider(name = "delays", parallel = true)
public static Iterator<Object[]> delays() {
  return IntStream.generate(() -> new Random().nextInt(3000)).
      limit(ForkJoinPool.getCommonPoolParallelism() * 10).
              boxed().
              map(i -> new Object[]{i}).
              collect(Collectors.toList()).
              iterator();
}

相关文章

微信公众号

最新文章

更多

ForkJoinPool类方法