Search in sources :

Example 16 with ForkJoinTask

use of java8.util.concurrent.ForkJoinTask 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 17 with ForkJoinTask

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

the class ForkJoinTaskTest method testAbnormalInvokeAllCollection.

/**
 * invokeAll(collection) throws exception if any task does
 */
public void testAbnormalInvokeAllCollection() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FailingAsyncFib f = new FailingAsyncFib(8);
            AsyncFib g = new AsyncFib(9);
            AsyncFib h = new AsyncFib(7);
            ForkJoinTask<?>[] tasks = { f, g, h };
            shuffle(tasks);
            try {
                invokeAll(Arrays.asList(tasks));
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }
    };
    testInvokeOnPool(mainPool(), a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction) ForkJoinTask(java8.util.concurrent.ForkJoinTask)

Aggregations

ForkJoinTask (java8.util.concurrent.ForkJoinTask)10 RecursiveAction (java8.util.concurrent.RecursiveAction)10 ForkJoinPool (java8.util.concurrent.ForkJoinPool)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 ForkJoinWorkerThread (java8.util.concurrent.ForkJoinWorkerThread)1