use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testCancelledForkJoin.
/**
* join of a forked task throws exception when task cancelled
*/
public void testCancelledForkJoin() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
assertTrue(f.cancel(true));
assertSame(f, f.fork());
try {
f.join();
shouldThrow();
} catch (CancellationException success) {
checkCancelled(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest 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);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testAbnormalForkTimedGet.
/**
* timed get of a forked task throws exception when task completes abnormally
*/
public void testAbnormalForkTimedGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FailingFibAction f = new FailingFibAction(8);
assertSame(f, f.fork());
try {
f.get(LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (ExecutionException success) {
Throwable cause = success.getCause();
assertTrue(cause instanceof FJException);
checkCompletedAbnormally(f, cause);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testForkJoin.
/**
* join of a forked task returns when task completes
*/
public void testForkJoin() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
assertSame(f, f.fork());
assertNull(f.join());
assertEquals(21, f.result);
checkCompletedNormally(f);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testCompleteExceptionally.
/**
* invoke task throws exception after invoking completeExceptionally
*/
public void testCompleteExceptionally() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
f.completeExceptionally(new FJException());
try {
f.invoke();
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(f, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations