use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalInvokeAll3Singleton.
/**
* invokeAll(tasks) with > 2 argument throws exception if any task does
*/
public void testAbnormalInvokeAll3Singleton() {
@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(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testForkQuietlyJoinSingleton.
/**
* quietlyJoin of a forked task returns when task completes
*/
public void testForkQuietlyJoinSingleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
f.quietlyJoin();
assertEquals(21, f.number);
checkCompletedNormally(f);
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testForkTimedGet.
/**
* timed get of a forked task returns when task completes
*/
public void testForkTimedGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
assertEquals(21, f.number);
checkCompletedNormally(f);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testForkGet.
/**
* get of a forked task returns when task completes
*/
public void testForkGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
assertNull(f.get());
assertEquals(21, f.number);
checkCompletedNormally(f);
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testPollNextLocalTask.
/**
* pollNextLocalTask returns most recent unexecuted task without
* executing it
*/
public void testPollNextLocalTask() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib g = new AsyncFib(9);
assertSame(g, g.fork());
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
assertSame(f, pollNextLocalTask());
helpQuiesce();
checkNotDone(f);
assertEquals(34, g.number);
checkCompletedNormally(g);
}
};
testInvokeOnPool(singletonPool(), a);
}
Aggregations