use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvokeAll2Singleton.
/**
* invokeAll(t1, t2) throw exception if any task does
*/
public void testAbnormalInvokeAll2Singleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
FailingAsyncFib g = new FailingAsyncFib(9);
ForkJoinTask<?>[] tasks = { f, g };
shuffle(tasks);
try {
invokeAll(tasks);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvokeAll2.
/**
* invokeAll(t1, t2) throw exception if any task does
*/
public void testAbnormalInvokeAll2() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
FailingAsyncFib g = new FailingAsyncFib(9);
ForkJoinTask<?>[] tasks = { f, g };
shuffle(tasks);
try {
invokeAll(tasks);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvokeAll3.
/**
* invokeAll(tasks) with > 2 argument throws exception if any task does
*/
public void testAbnormalInvokeAll3() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
FailingAsyncFib g = new FailingAsyncFib(9);
AsyncFib h = new AsyncFib(7);
ForkJoinTask<?>[] tasks = { f, g, h };
shuffle(tasks);
try {
invokeAll(tasks);
shouldThrow();
} catch (FJException success) {
checkCompletedAbnormally(g, success);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testGetSurplusQueuedTaskCount.
/**
* getSurplusQueuedTaskCount returns > 0 when
* there are more tasks than threads
*/
public void testGetSurplusQueuedTaskCount() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib h = new AsyncFib(7);
assertSame(h, h.fork());
AsyncFib g = new AsyncFib(9);
assertSame(g, g.fork());
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
assertTrue(getSurplusQueuedTaskCount() > 0);
helpQuiesce();
assertEquals(0, getSurplusQueuedTaskCount());
checkCompletedNormally(f);
checkCompletedNormally(g);
checkCompletedNormally(h);
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testInvokeAll2Singleton.
/**
* invokeAll(t1, t2) invokes all task arguments
*/
public void testInvokeAll2Singleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
AsyncFib g = new AsyncFib(9);
invokeAll(f, g);
assertEquals(21, f.number);
assertEquals(34, g.number);
checkCompletedNormally(f);
checkCompletedNormally(g);
}
};
testInvokeOnPool(singletonPool(), a);
}
Aggregations