use of java.util.concurrent.CancellationException in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testCancelledForkJoin.
/**
* join of a forked task throws exception when task cancelled
*/
public void testCancelledForkJoin() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
assertTrue(f.cancel(true));
assertSame(f, f.fork());
try {
f.join();
shouldThrow();
} catch (CancellationException success) {
checkCancelled(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java.util.concurrent.CancellationException in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testCancelledInvoke.
/**
* invoke task throws exception when task cancelled
*/
public void testCancelledInvoke() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
assertTrue(f.cancel(true));
try {
f.invoke();
shouldThrow();
} catch (CancellationException success) {
checkCancelled(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java.util.concurrent.CancellationException 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 java.util.concurrent.CancellationException 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 java.util.concurrent.CancellationException in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testCancelledForkJoin.
/**
* join of a forked task throws exception when task cancelled
*/
public void testCancelledForkJoin() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
assertTrue(f.cancel(true));
assertSame(f, f.fork());
try {
f.join();
shouldThrow();
} catch (CancellationException success) {
checkCancelled(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations