use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest 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 testQuietlyInvoke.
/**
* quietlyInvoke task returns when task completes normally.
* isCompletedAbnormally and isCancelled return false for normally
* completed tasks
*/
public void testQuietlyInvoke() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
f.quietlyInvoke();
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 testComplete.
/**
* invoke task suppresses execution invoking complete
*/
public void testComplete() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
f.complete(null);
assertNull(f.invoke());
assertEquals(0, f.result);
checkCompletedNormally(f);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testInvokeAll3.
/**
* invokeAll(tasks) with > 2 argument invokes tasks
*/
public void testInvokeAll3() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
FibAction g = new FibAction(9);
FibAction h = new FibAction(7);
invokeAll(f, g, h);
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 testReinitialize.
/**
* A reinitialized normally completed task may be re-invoked
*/
public void testReinitialize() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
checkNotDone(f);
for (int i = 0; i < 3; i++) {
assertNull(f.invoke());
assertEquals(21, f.result);
checkCompletedNormally(f);
f.reinitialize();
checkNotDone(f);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations