org.codehaus.gpars

groovyx.gpars.forkjoin
[Java] Class AbstractForkJoinWorker

java.lang.Object
  jsr166y.ForkJoinTask
      jsr166y.RecursiveTask
          groovyx.gpars.forkjoin.AbstractForkJoinWorker

public abstract class AbstractForkJoinWorker
extends jsr166y.RecursiveTask

Implements the ForkJoin worker contract. Subclasses need to implement the compute() to perform the actual Fork/Join algorithm leveraging the options provided by the AbstractForkJoinWorker class. The AbstractForJoinWorker class takes care of the child sub-processes.

Author: Vaclav Pech Date: Nov 1, 2009


Field Summary
private java.util.List children

Stores the child workers

 
Constructor Summary
protected AbstractForkJoinWorker()

 
Method Summary
protected T compute()

protected T computeTask()

protected void forkOffChild(AbstractForkJoinWorker child)

Forks a child task.

java.util.List getChildrenResults()

Waits for and returns the results of the child tasks.

 
Methods inherited from class jsr166y.RecursiveTask
jsr166y.RecursiveTask#getRawResult(), jsr166y.RecursiveTask#invoke(), jsr166y.RecursiveTask#get(), jsr166y.RecursiveTask#get(long, java.util.concurrent.TimeUnit), jsr166y.RecursiveTask#getException(), jsr166y.RecursiveTask#join(), jsr166y.RecursiveTask#complete(java.lang.Object), jsr166y.RecursiveTask#getPool(), jsr166y.RecursiveTask#cancel(boolean), jsr166y.RecursiveTask#fork(), jsr166y.RecursiveTask#isCancelled(), jsr166y.RecursiveTask#invokeAll(jsr166y.ForkJoinTask, jsr166y.ForkJoinTask), jsr166y.RecursiveTask#invokeAll([Ljsr166y.ForkJoinTask;), jsr166y.RecursiveTask#invokeAll(java.util.Collection), jsr166y.RecursiveTask#isDone(), jsr166y.RecursiveTask#isCompletedAbnormally(), jsr166y.RecursiveTask#isCompletedNormally(), jsr166y.RecursiveTask#completeExceptionally(java.lang.Throwable), jsr166y.RecursiveTask#quietlyJoin(), jsr166y.RecursiveTask#quietlyInvoke(), jsr166y.RecursiveTask#helpQuiesce(), jsr166y.RecursiveTask#reinitialize(), jsr166y.RecursiveTask#inForkJoinPool(), jsr166y.RecursiveTask#tryUnfork(), jsr166y.RecursiveTask#getQueuedTaskCount(), jsr166y.RecursiveTask#getSurplusQueuedTaskCount(), jsr166y.RecursiveTask#adapt(java.lang.Runnable, java.lang.Object), jsr166y.RecursiveTask#adapt(java.lang.Runnable), jsr166y.RecursiveTask#adapt(java.util.concurrent.Callable), jsr166y.RecursiveTask#wait(long), jsr166y.RecursiveTask#wait(), jsr166y.RecursiveTask#wait(long, int), jsr166y.RecursiveTask#equals(java.lang.Object), jsr166y.RecursiveTask#toString(), jsr166y.RecursiveTask#hashCode(), jsr166y.RecursiveTask#getClass(), jsr166y.RecursiveTask#notify(), jsr166y.RecursiveTask#notifyAll()
 
Methods inherited from class jsr166y.ForkJoinTask
jsr166y.ForkJoinTask#invoke(), jsr166y.ForkJoinTask#get(), jsr166y.ForkJoinTask#get(long, java.util.concurrent.TimeUnit), jsr166y.ForkJoinTask#getException(), jsr166y.ForkJoinTask#join(), jsr166y.ForkJoinTask#complete(java.lang.Object), jsr166y.ForkJoinTask#getPool(), jsr166y.ForkJoinTask#cancel(boolean), jsr166y.ForkJoinTask#fork(), jsr166y.ForkJoinTask#isCancelled(), jsr166y.ForkJoinTask#invokeAll(jsr166y.ForkJoinTask, jsr166y.ForkJoinTask), jsr166y.ForkJoinTask#invokeAll([Ljsr166y.ForkJoinTask;), jsr166y.ForkJoinTask#invokeAll(java.util.Collection), jsr166y.ForkJoinTask#isDone(), jsr166y.ForkJoinTask#getRawResult(), jsr166y.ForkJoinTask#isCompletedAbnormally(), jsr166y.ForkJoinTask#isCompletedNormally(), jsr166y.ForkJoinTask#completeExceptionally(java.lang.Throwable), jsr166y.ForkJoinTask#quietlyJoin(), jsr166y.ForkJoinTask#quietlyInvoke(), jsr166y.ForkJoinTask#helpQuiesce(), jsr166y.ForkJoinTask#reinitialize(), jsr166y.ForkJoinTask#inForkJoinPool(), jsr166y.ForkJoinTask#tryUnfork(), jsr166y.ForkJoinTask#getQueuedTaskCount(), jsr166y.ForkJoinTask#getSurplusQueuedTaskCount(), jsr166y.ForkJoinTask#adapt(java.lang.Runnable, java.lang.Object), jsr166y.ForkJoinTask#adapt(java.lang.Runnable), jsr166y.ForkJoinTask#adapt(java.util.concurrent.Callable), jsr166y.ForkJoinTask#wait(long), jsr166y.ForkJoinTask#wait(), jsr166y.ForkJoinTask#wait(long, int), jsr166y.ForkJoinTask#equals(java.lang.Object), jsr166y.ForkJoinTask#toString(), jsr166y.ForkJoinTask#hashCode(), jsr166y.ForkJoinTask#getClass(), jsr166y.ForkJoinTask#notify(), jsr166y.ForkJoinTask#notifyAll()
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

children

private java.util.List children
Stores the child workers


 
Constructor Detail

AbstractForkJoinWorker

protected AbstractForkJoinWorker()


 
Method Detail

compute

@Override
protected final T compute()


computeTask

protected T computeTask()


forkOffChild

protected final void forkOffChild(AbstractForkJoinWorker child)
Forks a child task. Makes sure it has a means to indicate back completion. The worker is stored in the internal list of workers for evidence and easy result retrieval through getChildrenResults().
Parameters:
child - The child task


getChildrenResults

@SuppressWarnings({"unchecked"})
public final java.util.List getChildrenResults()
Waits for and returns the results of the child tasks.
Returns:
A list of results returned from the child tasks


 

Copyright © 2008–2010 Václav Pech. All Rights Reserved.