use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinPool8Test method testCancelledForkTimedGet.
/**
* timed get of a forked task throws exception when task cancelled
*/
public void testCancelledForkTimedGet() {
@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(LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (CancellationException success) {
checkCancelled(f);
}
}
};
checkInvoke(a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinPool8Test 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);
}
}
};
checkInvoke(a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinPool8Test method testAbnormalForkGet.
/**
* get of a forked task throws exception when task completes abnormally
*/
public void testAbnormalForkGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FailingFibAction f = new FailingFibAction(8);
assertSame(f, f.fork());
try {
f.get();
shouldThrow();
} catch (ExecutionException success) {
Throwable cause = success.getCause();
assertTrue(cause instanceof FJException);
checkCompletedAbnormally(f, cause);
}
}
};
checkInvoke(a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinPool8Test method testCancelledForkQuietlyJoin.
/**
* quietlyJoin of a forked task returns when task cancelled
*/
public void testCancelledForkQuietlyJoin() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
assertTrue(f.cancel(true));
assertSame(f, f.fork());
f.quietlyJoin();
checkCancelled(f);
}
};
checkInvoke(a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinPool8Test 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);
}
}
};
checkInvoke(a);
}
Aggregations