use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTask8Test method testQuietlyInvoke.
private void testQuietlyInvoke(ForkJoinPool pool) {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
f.quietlyInvoke();
f.checkCompletedNormally();
}
};
testInvokeOnPool(pool, a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTask8Test method testQuietlyComplete.
/**
* ForkJoinTask.quietlyComplete returns when task completes
* normally without setting a value. The most recent value
* established by setRawResult(V) (or null by default) is returned
* from invoke.
*/
public void testQuietlyComplete() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
f.quietlyComplete();
assertEquals(8, f.number);
assertTrue(f.isDone());
assertFalse(f.isCancelled());
assertTrue(f.isCompletedNormally());
assertFalse(f.isCompletedAbnormally());
assertNull(f.getException());
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTask8Test method testInForkJoinPool.
private void testInForkJoinPool(ForkJoinPool pool) {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
assertTrue(inForkJoinPool());
}
};
testInvokeOnPool(pool, a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTask8Test method testInForkJoinPool2.
/**
* inForkJoinPool of non-FJ task returns false
*/
public void testInForkJoinPool2() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
assertFalse(inForkJoinPool());
}
};
assertNull(a.invoke());
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest 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);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations