use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvoke.
/**
* invoke task throws exception when task completes abnormally
*/
public void testAbnormalInvoke() {
@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(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testInvokeAll1Singleton.
/**
* invokeAll(tasks) with 1 argument invokes task
*/
public void testInvokeAll1Singleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
invokeAll(f);
checkCompletedNormally(f);
assertEquals(21, f.number);
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testInvokeAll3.
/**
* invokeAll(tasks) with > 2 argument invokes tasks
*/
public void testInvokeAll3() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
AsyncFib g = new AsyncFib(9);
AsyncFib h = new AsyncFib(7);
invokeAll(f, g, h);
assertEquals(21, f.number);
assertEquals(34, g.number);
assertEquals(13, h.number);
checkCompletedNormally(f);
checkCompletedNormally(g);
checkCompletedNormally(h);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testCancelledForkTimedGet.
/**
* timed get of a forked task throws exception when task cancelled
*/
public void testCancelledForkTimedGet() throws Exception {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
AsyncFib f = new AsyncFib(8);
assertTrue(f.cancel(true));
assertSame(f, f.fork());
try {
f.get(LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (CancellationException success) {
checkCancelled(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testCompleteExceptionallySingleton.
/**
* invoke task throws exception after invoking completeExceptionally
*/
public void testCompleteExceptionallySingleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
f.completeExceptionally(new FJException());
try {
f.invoke();
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(f, success);
}
}
};
testInvokeOnPool(singletonPool(), a);
}
Aggregations