Examples of ForkJoinPool


Examples of java.util.concurrent.ForkJoinPool

    }

    private static void test1() {
        // -Djava.util.concurrent.ForkJoinPool.common.parallelism=5

        ForkJoinPool commonPool = ForkJoinPool.commonPool();
        System.out.println(commonPool.getParallelism());
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        addExpectation(expectations, client, 200, 3600, createPackageFeed("feed-19", 200, 3601));
        addExpectation(expectations, client, 200, 3800, createPackageFeed("feed-20", 200, 3801));
        context.checking(expectations);
        GetRemotePackageFeedAction instance = new GetRemotePackageFeedAction(200, arrayList, 0, 4000, clientFactory);
        //WHEN
        ForkJoinPool pool = new ForkJoinPool();
        pool.invoke(instance);
        //THEN
        context.assertIsSatisfied();
        assertThat(arrayList.size(), is(equalTo(4000)));
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

  /**Render that uses the given thread pool for parallel operations.
   *
   * @param pool -- Thread pool to use.  Null to create a pool
   * **/
  public ParallelRenderer(ForkJoinPool pool, int threadLoad, long transferTaskSize) {
    this.pool = pool != null ? pool : new ForkJoinPool(RENDER_POOL_SIZE);
    this.threadLoad = threadLoad > 0 ? threadLoad : RENDER_THREAD_LOAD;
    this.transferTaskSize = transferTaskSize > 0 ? transferTaskSize : DEFAULT_TRANSFER_TASK_SIZE;
  }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

  }
 
  /**Bounds calculation.  Is run in parallel using the tuning parameters of ParallelRenderer.**/
  public Rectangle2D bounds() {
    if (bounds == null) {
      ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
      bounds = pool.invoke(
          new BoundsTask<>(
              this,
              ParallelRenderer.RENDER_POOL_SIZE
                * ParallelRenderer.RENDER_THREAD_LOAD));
    }
 
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

  }
 
 
  public Rectangle2D bounds(int m) {
    int procs = Runtime.getRuntime().availableProcessors();
    ForkJoinPool pool = new ForkJoinPool(procs);
    bounds = pool.invoke(new BoundsTask<>(this, m*procs));
    return bounds;
  }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

    public MetricsForkJoinPoolMonitor(String name, ForkJoinPool fjPool) {
        super(name, fjPool);
        Metrics.register(metric(name, "status"), new Gauge<Status>() {
            @Override
            public Status getValue() {
                final ForkJoinPool fjPool = fjPool();
                if (fjPool.isTerminated()) // Returns true if all tasks have completed following shut down.
                    return ForkJoinPoolMonitor.Status.TERMINATED;
                if (fjPool.isTerminating()) // Returns true if the process of termination has commenced but not yet completed.
                    return ForkJoinPoolMonitor.Status.TERMINATING;
                if (fjPool.isShutdown()) // Returns true if this pool has been shut down.
                    return ForkJoinPoolMonitor.Status.SHUTDOWN;
                if (fjPool.isQuiescent()) // Returns true if all worker threads are currently idle.
                    return ForkJoinPoolMonitor.Status.QUIESCENT;
                return ForkJoinPoolMonitor.Status.ACTIVE;
            }
        });
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        return name("co.paralleluniverse", "fjPool", poolName, name);
    }

    @Override
    protected ForkJoinPool fjPool() {
        final ForkJoinPool fjPool = super.fjPool();
        if (fjPool == null) {
            unregister();
            throw new RuntimeException("Pool collected");
        }
        return fjPool;
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

    public void unregister() {
    }

    protected ForkJoinPool fjPool() {
        final ForkJoinPool fjp = this.fjPool.get();
        return fjp;
    }
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        return registered;
    }

    @Override
    protected ForkJoinPool fjPool() {
        final ForkJoinPool fjPool = super.fjPool();
        if (fjPool == null) {
            unregister();
            throw new RuntimeException("Pool collected");
        }
        return fjPool;
View Full Code Here

Examples of java.util.concurrent.ForkJoinPool

        return fjPool;
    }

    @Override
    public ForkJoinPoolMonitor.Status getStatus() {
        final ForkJoinPool fjPool = fjPool();
        if (fjPool.isTerminated()) // Returns true if all tasks have completed following shut down.
            return ForkJoinPoolMonitor.Status.TERMINATED;
        if (fjPool.isTerminating()) // Returns true if the process of termination has commenced but not yet completed.
            return ForkJoinPoolMonitor.Status.TERMINATING;
        if (fjPool.isShutdown()) // Returns true if this pool has been shut down.
            return ForkJoinPoolMonitor.Status.SHUTDOWN;
        if (fjPool.isQuiescent()) // Returns true if all worker threads are currently idle.
            return ForkJoinPoolMonitor.Status.QUIESCENT;
        return ForkJoinPoolMonitor.Status.ACTIVE;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.