Search in sources :

Example 31 with ForkJoinPool

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

the class ForkJoinTask8Test method testForkGet.

private void testForkGet(ForkJoinPool pool) {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() throws Exception {
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertNull(f.get());
            f.checkCompletedNormally();
        }
    };
    testInvokeOnPool(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 32 with ForkJoinPool

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

the class ForkJoinTask8Test method testAbnormalQuietlyInvoke.

private void testAbnormalQuietlyInvoke(ForkJoinPool pool) {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FailingAsyncFib f = new FailingAsyncFib(8);
            f.quietlyInvoke();
            assertTrue(f.getException() instanceof FJException);
            checkCompletedAbnormally(f, f.getException());
        }
    };
    testInvokeOnPool(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 33 with ForkJoinPool

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

the class ForkJoinTask8Test method testInvokeAllNullTask.

private void testInvokeAllNullTask(ForkJoinPool pool) {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            AsyncFib nul = null;
            Runnable[] throwingActions = { () -> invokeAll(nul), () -> invokeAll(nul, nul), () -> invokeAll(new AsyncFib(8), new AsyncFib(9), nul), () -> invokeAll(new AsyncFib(8), nul, new AsyncFib(9)), () -> invokeAll(nul, new AsyncFib(8), new AsyncFib(9)) };
            assertThrows(NullPointerException.class, throwingActions);
        }
    };
    testInvokeOnPool(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 34 with ForkJoinPool

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

the class ForkJoinTask8Test method testAbnormalInvoke.

private void testAbnormalInvoke(ForkJoinPool pool) {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FailingAsyncFib f = new FailingAsyncFib(8);
            try {
                f.invoke();
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }
    };
    testInvokeOnPool(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 35 with ForkJoinPool

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

the class ForkJoinTask8Test method testForkQuietlyJoin.

private void testForkQuietlyJoin(ForkJoinPool pool) {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            f.quietlyJoin();
            f.checkCompletedNormally();
        }
    };
    testInvokeOnPool(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

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