use of java8.util.concurrent.ForkJoinTask in project streamsupport by stefan-zobel.
the class ForkJoinPoolTest method testSubmitForkJoinTask.
/**
* Completed submit(ForkJoinTask) returns result
*/
public void testSubmitForkJoinTask() throws Throwable {
ForkJoinPool p = new ForkJoinPool(1);
PoolCleaner cleaner = null;
try {
cleaner = cleaner(p);
ForkJoinTask<Integer> f = p.submit(new FibTask(8));
assertEquals(21, (int) f.get());
} finally {
if (cleaner != null) {
cleaner.close();
}
}
}
use of java8.util.concurrent.ForkJoinTask 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);
}
use of java8.util.concurrent.ForkJoinTask in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvokeAll2Singleton.
/**
* invokeAll(t1, t2) throw exception if any task does
*/
public void testAbnormalInvokeAll2Singleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
FailingAsyncFib g = new FailingAsyncFib(9);
ForkJoinTask<?>[] tasks = { f, g };
shuffle(tasks);
try {
invokeAll(tasks);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.ForkJoinTask in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvokeAll2.
/**
* invokeAll(t1, t2) throw exception if any task does
*/
public void testAbnormalInvokeAll2() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
FailingAsyncFib g = new FailingAsyncFib(9);
ForkJoinTask<?>[] tasks = { f, g };
shuffle(tasks);
try {
invokeAll(tasks);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.ForkJoinTask in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest 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() {
AsyncFib f = new AsyncFib(8);
FailingAsyncFib g = new FailingAsyncFib(9);
AsyncFib h = new AsyncFib(7);
ForkJoinTask<?>[] tasks = { f, g, h };
shuffle(tasks);
try {
invokeAll(tasks);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations