java.util.concurrent.RecursiveAction Java Examples
The following examples show how to use
java.util.concurrent.RecursiveAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ForkJoinTask8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * getSurplusQueuedTaskCount returns > 0 when * there are more tasks than threads */ public void testGetSurplusQueuedTaskCount() { 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()); f.checkCompletedNormally(); g.checkCompletedNormally(); h.checkCompletedNormally(); }}; testInvokeOnPool(singletonPool(), a); }
Example #2
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * peekNextLocalTask returns least recent unexecuted task in async mode */ public void testPeekNextLocalTaskAsync() { 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(g, peekNextLocalTask()); assertNull(f.join()); helpQuiesce(); checkCompletedNormally(f); assertEquals(34, g.number); checkCompletedNormally(g); }}; testInvokeOnPool(asyncSingletonPool(), a); }
Example #3
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollection() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingAsyncFib f = new FailingAsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(Arrays.asList(tasks)); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(f, success); } }}; testInvokeOnPool(mainPool(), a); }
Example #4
Source File: RecursiveActionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * A reinitialized normally completed task may be re-invoked */ public void testReinitialize() { 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); }
Example #5
Source File: ForkJoinTask8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void testAbnormalForkTimedGet(ForkJoinPool pool) { 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(pool, a); }
Example #6
Source File: ForkJoinTask8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void testAbnormalForkGet(ForkJoinPool pool) { 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(pool, a); }
Example #7
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGet() { 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); }
Example #8
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * getSurplusQueuedTaskCount returns > 0 when * there are more tasks than threads */ public void testGetSurplusQueuedTaskCount() { 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); }
Example #9
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGetSingleton() throws Exception { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { AsyncFib f = new AsyncFib(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { f.get(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); } }}; testInvokeOnPool(singletonPool(), a); }
Example #10
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGetSingleton() { 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); }
Example #11
Source File: RecursiveActionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollection() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); FibAction g = new FibAction(9); FibAction h = new FibAction(7); HashSet set = new HashSet(); set.add(f); set.add(g); set.add(h); invokeAll(set); 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); }
Example #12
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3() { 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); }
Example #13
Source File: RecursiveActionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { 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()); assertSame(f, peekNextLocalTask()); assertNull(f.join()); checkCompletedNormally(f); helpQuiesce(); checkCompletedNormally(f); checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); }
Example #14
Source File: RecursiveActionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * get of a forked task throws exception when task cancelled */ public void testCancelledForkGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FibAction f = new FibAction(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { f.get(); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); } }}; testInvokeOnPool(mainPool(), a); }
Example #15
Source File: ForkJoinPool8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3() { 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); }}; checkInvoke(a); }
Example #16
Source File: ForkJoinTask8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void testAbnormalInvokeAll2(ForkJoinPool pool) { 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[0], tasks[1]); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(g, success); } }}; testInvokeOnPool(pool, a); }
Example #17
Source File: ForkJoinTask8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { 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, peekNextLocalTask()); assertNull(f.join()); f.checkCompletedNormally(); helpQuiesce(); g.checkCompletedNormally(); }}; testInvokeOnPool(singletonPool(), a); }
Example #18
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * get of a forked task throws exception when task cancelled */ public void testCancelledForkGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { AsyncFib f = new AsyncFib(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { f.get(); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); } }}; testInvokeOnPool(mainPool(), a); }
Example #19
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2() { 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); }
Example #20
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3Singleton() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { AsyncFib f = new AsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); invokeAll(f, g, h); assertEquals(21, f.number); assertEquals(34, g.number); assertEquals(13, h.number); checkCompletedNormally(f); checkCompletedNormally(g); checkCompletedNormally(h); }}; testInvokeOnPool(singletonPool(), a); }
Example #21
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollectionSingleton() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { AsyncFib f = new AsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); HashSet set = new HashSet(); set.add(f); set.add(g); set.add(h); invokeAll(set); assertEquals(21, f.number); assertEquals(34, g.number); assertEquals(13, h.number); checkCompletedNormally(f); checkCompletedNormally(g); checkCompletedNormally(h); }}; testInvokeOnPool(singletonPool(), a); }
Example #22
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * pollNextLocalTask returns most recent unexecuted task without * executing it */ public void testPollNextLocalTask() { 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); }
Example #23
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGet() { 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(mainPool(), a); }
Example #24
Source File: ForkJoinPool8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FibAction f = new FibAction(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { f.get(5L, SECONDS); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); } }}; checkInvoke(a); }
Example #25
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * pollNextLocalTask returns least recent unexecuted task without * executing it, in async mode */ public void testPollNextLocalTaskAsync() { 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(g, pollNextLocalTask()); helpQuiesce(); assertEquals(21, f.number); checkCompletedNormally(f); checkNotDone(g); }}; testInvokeOnPool(asyncSingletonPool(), a); }
Example #26
Source File: ForkJoinPool8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoin() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { f.join(); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); } }}; checkInvoke(a); }
Example #27
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3Singleton() { 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); }
Example #28
Source File: RecursiveActionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingFibAction f = new FailingFibAction(8); assertSame(f, f.fork()); try { f.get(5L, SECONDS); shouldThrow(); } catch (ExecutionException success) { Throwable cause = success.getCause(); assertTrue(cause instanceof FJException); checkCompletedAbnormally(f, cause); } }}; testInvokeOnPool(mainPool(), a); }
Example #29
Source File: ForkJoinTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { 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, peekNextLocalTask()); assertNull(f.join()); checkCompletedNormally(f); helpQuiesce(); checkCompletedNormally(g); }}; testInvokeOnPool(singletonPool(), a); }
Example #30
Source File: ForkJoinPool8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGet() { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingFibAction f = new FailingFibAction(8); assertSame(f, f.fork()); try { f.get(); shouldThrow(); } catch (ExecutionException success) { Throwable cause = success.getCause(); assertTrue(cause instanceof FJException); checkCompletedAbnormally(f, cause); } }}; checkInvoke(a); }