use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testInvokeAll2.
/**
* invokeAll(t1, t2) invokes all task arguments
*/
public void testInvokeAll2() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
FibAction g = new FibAction(9);
invokeAll(f, g);
checkCompletedNormally(f);
assertEquals(21, f.result);
checkCompletedNormally(g);
assertEquals(34, g.result);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testForkGet.
/**
* get of a forked task returns when task completes
*/
public void testForkGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FibAction f = new FibAction(8);
assertSame(f, f.fork());
assertNull(f.get());
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 testReinitializeAbnormal.
/**
* A reinitialized abnormally completed task may be re-invoked
*/
public void testReinitializeAbnormal() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FailingFibAction f = new FailingFibAction(8);
checkNotDone(f);
for (int i = 0; i < 3; i++) {
try {
f.invoke();
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(f, success);
}
f.reinitialize();
checkNotDone(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testInvokeAllCollection.
/**
* invokeAll(collection) invokes all tasks in the collection
*/
public void testInvokeAllCollection() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
FibAction g = new FibAction(9);
FibAction h = new FibAction(7);
HashSet<FibAction> set = new HashSet<>();
set.add(f);
set.add(g);
set.add(h);
invokeAll(set);
assertTrue(f.isDone());
assertTrue(g.isDone());
assertTrue(h.isDone());
checkCompletedNormally(f);
assertEquals(21, f.result);
checkCompletedNormally(g);
assertEquals(34, g.result);
checkCompletedNormally(g);
assertEquals(13, h.result);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testAbnormalForkQuietlyJoin.
/**
* quietlyJoin of a forked task returns when task completes abnormally
*/
public void testAbnormalForkQuietlyJoin() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FailingFibAction f = new FailingFibAction(8);
assertSame(f, f.fork());
f.quietlyJoin();
assertTrue(f.getException() instanceof FJException);
checkCompletedAbnormally(f, f.getException());
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations