Search in sources :

Example 16 with RecursiveAction

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

the class ForkJoinPool8Test method testAbnormalInvokeAll3.

/**
 * invokeAll(tasks) with > 2 argument throws exception if any task does
 */
public void testAbnormalInvokeAll3() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FibAction f = new FibAction(8);
            FailingFibAction g = new FailingFibAction(9);
            FibAction h = new FibAction(7);
            try {
                invokeAll(f, g, h);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(g, success);
            }
        }
    };
    checkInvoke(a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 17 with RecursiveAction

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

the class ForkJoinTask8Test method testAbnormalForkQuietlyJoin.

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

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

Example 18 with RecursiveAction

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

the class ForkJoinTask8Test method testInvokeAll2.

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

        protected void realCompute() {
            AsyncFib[] tasks = { new AsyncFib(8), new AsyncFib(9) };
            invokeAll(tasks[0], tasks[1]);
            for (AsyncFib task : tasks) assertTrue(task.isDone());
            for (AsyncFib task : tasks) task.checkCompletedNormally();
        }
    };
    testInvokeOnPool(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 19 with RecursiveAction

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

the class ForkJoinTask8Test method testAbnormalInvokeAllCollection.

private void testAbnormalInvokeAllCollection(ForkJoinPool pool) {
    @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(pool, a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction) ForkJoinTask(java8.util.concurrent.ForkJoinTask)

Example 20 with RecursiveAction

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

the class ForkJoinTask8Test method testSetRawResult.

/**
 * setRawResult(null) succeeds
 */
public void testSetRawResult() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            setRawResult(null);
            assertNull(getRawResult());
        }
    };
    assertNull(a.invoke());
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Aggregations

RecursiveAction (java8.util.concurrent.RecursiveAction)194 CancellationException (java.util.concurrent.CancellationException)19 ExecutionException (java.util.concurrent.ExecutionException)11 ForkJoinTask (java8.util.concurrent.ForkJoinTask)9 HashSet (java.util.HashSet)6 ForkJoinPool (java8.util.concurrent.ForkJoinPool)5 ForkJoinWorkerThread (java8.util.concurrent.ForkJoinWorkerThread)5 CountDownLatch (java.util.concurrent.CountDownLatch)1 SynchronousQueue (java.util.concurrent.SynchronousQueue)1 TimeoutException (java.util.concurrent.TimeoutException)1