Search in sources :

Example 96 with RecursiveAction

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

the class ForkJoinTaskTest method testAbnormalInvokeAll1.

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

        protected void realCompute() {
            FailingAsyncFib g = new FailingAsyncFib(9);
            try {
                invokeAll(g);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(g, success);
            }
        }
    };
    testInvokeOnPool(mainPool(), a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 97 with RecursiveAction

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

the class ForkJoinPool8Test method testCancelledInvoke.

/**
 * invoke task throws exception when task cancelled
 */
public void testCancelledInvoke() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FibAction f = new FibAction(8);
            assertTrue(f.cancel(true));
            try {
                f.invoke();
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }
    };
    checkInvoke(a);
}
Also used : CancellationException(java.util.concurrent.CancellationException) RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 98 with RecursiveAction

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

the class ForkJoinPool8Test method testInvokeAllNPE.

/**
 * invokeAll(tasks) with any null task throws NPE
 */
public void testInvokeAllNPE() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

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

Example 99 with RecursiveAction

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

the class ForkJoinPool8Test method testForkQuietlyJoin.

/**
 * quietlyJoin of a forked task returns when task completes
 */
public void testForkQuietlyJoin() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FibAction f = new FibAction(8);
            assertSame(f, f.fork());
            f.quietlyJoin();
            assertEquals(21, f.result);
            checkCompletedNormally(f);
        }
    };
    checkInvoke(a);
}
Also used : RecursiveAction(java8.util.concurrent.RecursiveAction)

Example 100 with RecursiveAction

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

the class ForkJoinPool8Test method testAbnormalInvoke.

/**
 * invoke task throws exception when task completes abnormally
 */
public void testAbnormalInvoke() {
    @SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {

        protected void realCompute() {
            FailingFibAction f = new FailingFibAction(8);
            try {
                f.invoke();
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }
    };
    checkInvoke(a);
}
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