Examples of ForkJoinPool


Examples of java.util.concurrent.ForkJoinPool

        return new ExecutorServiceLatencyProbe(fjPool(), 5).fire();
    }
   
    @Override
    public ForkJoinInfo getInfo() {
        final ForkJoinPool fjPool = fjPool();
        int activeThreadCount = fjPool.getActiveThreadCount(); // Returns an estimate of the number of threads that are currently stealing or executing tasks.
        int runningThreadCount = fjPool.getRunningThreadCount(); // Returns an estimate of the number of worker threads that are not blocked waiting to join tasks or for other managed synchronization.
        int queuedSumbmissionCount = fjPool.getQueuedSubmissionCount(); // Returns an estimate of the number of tasks submitted to this pool that have not yet begun executing.
        long queuedTaskCount = fjPool.getQueuedTaskCount(); // Returns an estimate of the total number of tasks currently held in queues by worker threads (but not including tasks submitted to the pool that have not begun executing).
        long stealCount = fjPool.getStealCount(); //  Returns an estimate of the total number of tasks stolen from one thread's work queue by another.

        return new ForkJoinInfo(activeThreadCount, runningThreadCount, queuedSumbmissionCount, queuedTaskCount, stealCount);
    }
View Full Code Here

Examples of jsr166e.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 jsr166e.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

Examples of jsr166e.ForkJoinPool

        return new ExecutorServiceLatencyProbe(fjPool(), 5).fire();
    }
   
    @Override
    public ForkJoinInfo getInfo() {
        final ForkJoinPool fjPool = fjPool();
        int activeThreadCount = fjPool.getActiveThreadCount(); // Returns an estimate of the number of threads that are currently stealing or executing tasks.
        int runningThreadCount = fjPool.getRunningThreadCount(); // Returns an estimate of the number of worker threads that are not blocked waiting to join tasks or for other managed synchronization.
        int queuedSumbmissionCount = fjPool.getQueuedSubmissionCount(); // Returns an estimate of the number of tasks submitted to this pool that have not yet begun executing.
        long queuedTaskCount = fjPool.getQueuedTaskCount(); // Returns an estimate of the total number of tasks currently held in queues by worker threads (but not including tasks submitted to the pool that have not begun executing).
        long stealCount = fjPool.getStealCount(); //  Returns an estimate of the total number of tasks stolen from one thread's work queue by another.

        return new ForkJoinInfo(activeThreadCount, runningThreadCount, queuedSumbmissionCount, queuedTaskCount, stealCount);
    }
View Full Code Here

Examples of jsr166e.ForkJoinPool

    public void unregister() {
    }

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

Examples of jsr166e.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 jsr166e.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 jsr166y.ForkJoinPool

  @SuppressWarnings("boxing")
  public static void main(String[] args) throws Exception {
    String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    /* Create and configure a task pool manager (task executor) */
    ForkJoinPool taskExecutor = new ForkJoinPool();
    // Indicate to the task executor to use all processor of the current
    // machine
    taskExecutor.setParallelism(Runtime.getRuntime().availableProcessors());
    // In this sample tasks used here do not joined the we can disable the
    // AsyncMode (documentation
    // extract :
    // Establishes local first-in-first-out scheduling mode for forked tasks
    // that are never joined. This mode may be more appropriate than default
    // locally stack-based mode in applications in which worker threads only
    // process asynchronous tasks. This method is designed to be invoked
    // only when the pool is quiescent, and typically only before any tasks
    // are submitted. The effects of invocations at other times may be
    // unpredictable.)
    taskExecutor.setAsyncMode(false);
    // Indicate to the task executor to maintain parallelism
    taskExecutor.setMaintainsParallelism(true);

    /* Create a Phaser */
    Phaser phaser = new Phaser(alphabet.length());

    /* Create tasks */
    List<FileCounterRecursiveTaskWithPhaser> tasks = new ArrayList<FileCounterRecursiveTaskWithPhaser>(alphabet.length());
    for (char c : alphabet.toCharArray()) {
      tasks.add(new FileCounterRecursiveTaskWithPhaser(new File(c + ":\\"), phaser));
    }

    /* Launch tasks */
    for (FileCounterRecursiveTaskWithPhaser task : tasks) {
      taskExecutor.execute(task);
    }

    /*
     * Wait tasks termination using the Phaser and then display processing
     * state
 
View Full Code Here

Examples of jsr166y.ForkJoinPool

   *        Command line
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    /* Create and configure a task pool manager (task executor) */
    ForkJoinPool taskExecutor = new ForkJoinPool();
    // Indicate to the task executor to use all processor of the current
    // machine
    taskExecutor.setParallelism(Runtime.getRuntime().availableProcessors());
    // In this sample tasks used here do not joined the we can disable the
    // AsyncMode (documentation
    // extract :
    // Establishes local first-in-first-out scheduling mode for forked tasks
    // that are never joined. This mode may be more appropriate than default
    // locally stack-based mode in applications in which worker threads only
    // process asynchronous tasks. This method is designed to be invoked
    // only when the pool is quiescent, and typically only before any tasks
    // are submitted. The effects of invocations at other times may be
    // unpredictable.)
    taskExecutor.setAsyncMode(false);
    // Indicate to the task executor to maintain parallelism
    taskExecutor.setMaintainsParallelism(true);

    /* Create and launch tasks with the task executor */
    FileCounterRecursiveTask task01 = new FileCounterRecursiveTask(new File("C:\\"));
    FileCounterRecursiveTask task02 = new FileCounterRecursiveTask(new File("D:\\"));
    FileCounterRecursiveTask task03 = new FileCounterRecursiveTask(new File("E:\\"));
    // Explicit invalid path in order that the task fail !
    FileCounterRecursiveTask task04 = new FileCounterRecursiveTask(new File("A:\\"));
    taskExecutor.execute(task01);
    taskExecutor.execute(task02);
    taskExecutor.execute(task03);
    taskExecutor.execute(task04);
    System.out.println("Tasks launched...");

    /* Close the pool */
    taskExecutor.shutdown();

    /*
     * Wait tasks termination (limit waiting to 15 minutes) and then display
     * processing state
     */
    boolean terminationState = taskExecutor.awaitTermination(15, TimeUnit.MINUTES);
    if (terminationState) {
      System.out.println("All tasks have finished their processing under the timeout !");
    } else {
      System.out.println("All tasks do not have finished their processing until the timeout !");
    }
View Full Code Here

Examples of jsr166y.ForkJoinPool

   *        Command line
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    /* Create and configure a task pool manager (task executor) */
    ForkJoinPool taskExecutor = new ForkJoinPool();
    // Indicate to the task executor to use all processor of the current
    // machine
    taskExecutor.setParallelism(Runtime.getRuntime().availableProcessors());
    // In this sample tasks used here do not joined the we can disable the
    // AsyncMode (documentation
    // extract :
    // Establishes local first-in-first-out scheduling mode for forked tasks
    // that are never joined. This mode may be more appropriate than default
    // locally stack-based mode in applications in which worker threads only
    // process asynchronous tasks. This method is designed to be invoked
    // only when the pool is quiescent, and typically only before any tasks
    // are submitted. The effects of invocations at other times may be
    // unpredictable.)
    taskExecutor.setAsyncMode(false);
    // Indicate to the task executor to maintain parallelism
    taskExecutor.setMaintainsParallelism(true);

    /* Create and launch tasks with the task executor */
    FileCounterRecursiveAction task01 = new FileCounterRecursiveAction(new File("C:\\"));
    FileCounterRecursiveAction task02 = new FileCounterRecursiveAction(new File("D:\\"));
    FileCounterRecursiveAction task03 = new FileCounterRecursiveAction(new File("E:\\"));
    // Explicit invalid path in order that the task fail !
    FileCounterRecursiveAction task04 = new FileCounterRecursiveAction(new File("A:\\"));
    taskExecutor.execute(task01);
    taskExecutor.execute(task02);
    taskExecutor.execute(task03);
    taskExecutor.execute(task04);
    System.out.println("Tasks launched...");

    /* Close the pool */
    taskExecutor.shutdown();

    /*
     * Wait tasks termination (limit waiting to 15 minutes) and then display
     * processing state
     */
    boolean terminationState = taskExecutor.awaitTermination(15, TimeUnit.MINUTES);
    if (terminationState) {
      System.out.println("All tasks have finished their processing under the timeout !");
    } else {
      System.out.println("All tasks do not have finished their processing until the timeout !");
    }
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.