Search in sources :

Example 81 with ForkJoinPool

use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.

the class RecursiveTaskTest method testGetPool.

/**
 * getPool of executing task returns its pool
 */
public void testGetPool() {
    final ForkJoinPool mainPool = mainPool();
    @SuppressWarnings("serial") RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {

        public Integer realCompute() {
            assertSame(mainPool, getPool());
            return NoResult;
        }
    };
    assertSame(NoResult, testInvokeOnPool(mainPool, a));
}
Also used : ForkJoinPool(java8.util.concurrent.ForkJoinPool)

Example 82 with ForkJoinPool

use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.

the class CountedCompleterTest method testGetPool.

/**
 * getPool of executing task returns its pool
 */
public void testGetPool() {
    final ForkJoinPool mainPool = mainPool();
    @SuppressWarnings("serial") ForkJoinTask<?> a = new CheckedRecursiveAction() {

        protected void realCompute() {
            assertSame(mainPool, getPool());
        }
    };
    testInvokeOnPool(mainPool, a);
}
Also used : ForkJoinPool(java8.util.concurrent.ForkJoinPool)

Example 83 with ForkJoinPool

use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.

the class ForkJoinTaskTest method testGetPool.

/**
 * getPool of executing task returns its pool
 */
public void testGetPool() {
    final ForkJoinPool mainPool = mainPool();
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            assertSame(mainPool, getPool());
        }
    };
    testInvokeOnPool(mainPool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction) ForkJoinPool(java8.util.concurrent.ForkJoinPool)

Aggregations

ForkJoinPool (java8.util.concurrent.ForkJoinPool)55 ExecutorService (java.util.concurrent.ExecutorService)32 RecursiveAction (java8.util.concurrent.RecursiveAction)32 Callable (java.util.concurrent.Callable)20 ArrayList (java.util.ArrayList)15 ExecutionException (java.util.concurrent.ExecutionException)10 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)9 Future (java.util.concurrent.Future)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 ForkJoinWorkerThread (java8.util.concurrent.ForkJoinWorkerThread)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 ForkJoinTask (java8.util.concurrent.ForkJoinTask)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 CancellationException (java.util.concurrent.CancellationException)1 SynchronousQueue (java.util.concurrent.SynchronousQueue)1 TimeoutException (java.util.concurrent.TimeoutException)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Predicate (java8.util.function.Predicate)1