use of java8.util.concurrent.RecursiveAction 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);
}
use of java8.util.concurrent.RecursiveAction 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);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTask8Test method testGetSurplusQueuedTaskCount.
/**
* getSurplusQueuedTaskCount returns > 0 when
* there are more tasks than threads
*/
public void testGetSurplusQueuedTaskCount() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib h = new AsyncFib(7);
assertSame(h, h.fork());
AsyncFib g = new AsyncFib(9);
assertSame(g, g.fork());
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
assertTrue(getSurplusQueuedTaskCount() > 0);
helpQuiesce();
assertEquals(0, getSurplusQueuedTaskCount());
f.checkCompletedNormally();
g.checkCompletedNormally();
h.checkCompletedNormally();
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction 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);
}
use of java8.util.concurrent.RecursiveAction 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);
}
Aggregations