use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testWorkerGetPool.
/**
* getPool of current thread in pool returns its pool
*/
public void testWorkerGetPool() {
final ForkJoinPool mainPool = mainPool();
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
ForkJoinWorkerThread w = (ForkJoinWorkerThread) Thread.currentThread();
assertSame(mainPool, w.getPool());
}
};
testInvokeOnPool(mainPool, a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testTryUnfork.
/**
* tryUnfork returns true for most recent unexecuted task,
* and suppresses execution
*/
public void testTryUnfork() {
@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());
assertTrue(f.tryUnfork());
helpQuiesce();
checkNotDone(f);
checkCompletedNormally(g);
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testGetPool2.
/**
* getPool of non-FJ task returns null
*/
public void testGetPool2() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
assertNull(getPool());
}
};
assertNull(a.invoke());
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testForkTimedGetNPE.
/**
* timed get with null time unit throws NPE
*/
public void testForkTimedGetNPE() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FibAction f = new FibAction(8);
assertSame(f, f.fork());
try {
f.get(randomTimeout(), null);
shouldThrow();
} catch (NullPointerException success) {
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class RecursiveActionTest method testAbnormalInvoke.
/**
* invoke task throws exception when task completes abnormally
*/
public void testAbnormalInvoke() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FailingFibAction f = new FailingFibAction(8);
try {
f.invoke();
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(f, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
Aggregations