use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testAbnormalInvokeAllCollection.
/**
* invokeAll(collection) throws exception if any task does
*/
public void testAbnormalInvokeAllCollection() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FailingFibAction f = new FailingFibAction(8);
FibAction g = new FibAction(9);
FibAction h = new FibAction(7);
HashSet<RecursiveAction> set = new HashSet<>();
set.add(f);
set.add(g);
set.add(h);
try {
invokeAll(set);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(f, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testCancelledForkGet.
/**
* get of a forked task throws exception when task cancelled
*/
public void testCancelledForkGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FibAction f = new FibAction(8);
assertTrue(f.cancel(true));
assertSame(f, f.fork());
try {
f.get();
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 testPollNextLocalTask.
/**
* pollNextLocalTask returns most recent unexecuted task
* without executing it
*/
public void testPollNextLocalTask() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction g = new FibAction(9);
assertSame(g, g.fork());
FibAction f = new FibAction(8);
assertSame(f, f.fork());
assertSame(f, pollNextLocalTask());
helpQuiesce();
checkNotDone(f);
checkCompletedNormally(g);
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testPollTaskAsync.
/**
* pollTask returns an unexecuted task without executing it, in
* async mode
*/
public void testPollTaskAsync() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction g = new FibAction(9);
assertSame(g, g.fork());
FibAction f = new FibAction(8);
assertSame(f, f.fork());
assertSame(g, pollTask());
helpQuiesce();
checkCompletedNormally(f);
checkNotDone(g);
}
};
testInvokeOnPool(asyncSingletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testAbnormalInvokeAll2.
/**
* invokeAll(t1, t2) throw exception if any task does
*/
public void testAbnormalInvokeAll2() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
FailingFibAction g = new FailingFibAction(9);
try {
invokeAll(f, g);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations