use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testForkTimedGetNPE.
/**
* timed get with null time unit throws NPE
*/
public void testForkTimedGetNPE() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
AsyncFib f = new AsyncFib(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 ForkJoinTaskTest method testAbnormalForkTimedGet.
/**
* timed get of a forked task throws exception when task completes abnormally
*/
public void testAbnormalForkTimedGet() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FailingAsyncFib f = new FailingAsyncFib(8);
assertSame(f, f.fork());
try {
f.get(LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (ExecutionException success) {
Throwable cause = success.getCause();
assertTrue(cause instanceof FJException);
checkCompletedAbnormally(f, cause);
}
}
};
testInvokeOnPool(mainPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testForkHelpQuiesceSingleton.
/**
* helpQuiesce returns when tasks are complete.
* getQueuedTaskCount returns 0 when quiescent
*/
public void testForkHelpQuiesceSingleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
AsyncFib f = new AsyncFib(8);
assertSame(f, f.fork());
helpQuiesce();
assertEquals(0, getQueuedTaskCount());
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 testAbnormalQuietlyInvokeSingleton.
/**
* quietlyInvoke task returns when task completes abnormally
*/
public void testAbnormalQuietlyInvokeSingleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FailingAsyncFib f = new FailingAsyncFib(8);
f.quietlyInvoke();
assertTrue(f.getException() instanceof FJException);
checkCompletedAbnormally(f, f.getException());
}
};
testInvokeOnPool(singletonPool(), a);
}
use of java8.util.concurrent.RecursiveAction in project streamsupport by stefan-zobel.
the class ForkJoinTaskTest method testAbnormalForkGetSingleton.
/**
* get of a forked task throws exception when task completes abnormally
*/
public void testAbnormalForkGetSingleton() {
@SuppressWarnings("serial") RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws Exception {
FailingAsyncFib f = new FailingAsyncFib(8);
assertSame(f, f.fork());
try {
f.get();
shouldThrow();
} catch (ExecutionException success) {
Throwable cause = success.getCause();
assertTrue(cause instanceof FJException);
checkCompletedAbnormally(f, cause);
}
}
};
testInvokeOnPool(singletonPool(), a);
}
Aggregations