public class ExecutorServiceProcessingTask extends AbstractProcessingTask implements IExplicitProcessingTask
ExecutorService.| Modifier and Type | Class and Description |
|---|---|
(package private) class |
ExecutorServiceProcessingTask.ExecutorServiceWorkerThread |
SwingWorker.StateValue| Modifier and Type | Field and Description |
|---|---|
private List<ArrayList<ArrayList<IqmDataBox>>> |
allResultLists |
private Class<?> |
caller |
private static org.apache.log4j.Logger |
logger |
private int |
nItemsProcessed |
private int |
nStackItems |
private int |
nThreads |
private ExecutorService |
service |
childTask, duration, headless, operator, operatorGUI, parentTask, startTime, virtual, workPackage| Constructor and Description |
|---|
ExecutorServiceProcessingTask()
Empty default constructor.
|
ExecutorServiceProcessingTask(IWorkPackage wp,
boolean virtual,
int nThreads) |
ExecutorServiceProcessingTask(IWorkPackage wp,
boolean virtual,
IOperatorGUI opGUI,
int nThreads) |
| Modifier and Type | Method and Description |
|---|---|
private ArrayList<ArrayList<IqmDataBox>> |
addResultsToList(Result singleResult,
ArrayList<ArrayList<IqmDataBox>> resultList,
File virtDir)
A helper method for filling the final result list from an operator and
for optional writing of the processed items to the hard disk.
|
protected File |
createVirtDir() |
void |
decreaseNItemsProcessed() |
protected List<ArrayList<IqmDataBox>> |
doInBackground()
This method must be implemented by all subclasses.
|
protected void |
done()
This method is called after the
doInBackground() method and
must be implemented by all subclasses. |
private List<ArrayList<ArrayList<IqmDataBox>>> |
executeDefaultRoutine()
This method executes the operator of this task on each element
separately.
|
private List<ArrayList<ArrayList<IqmDataBox>>> |
executeMultiStackEvenRoutine()
This method executes the operator of this task in a serial manner across
two parallel item stacks of the same size.
|
private List<ArrayList<ArrayList<IqmDataBox>>> |
executeMultiStackOddRoutine()
This method executes the operator of this task in a serial manner across
one item stack and a single item.
|
int |
getNItemsProcessed() |
int |
getnThreads() |
void |
increaseNItemsProcessed() |
protected List<ArrayList<IqmDataBox>> |
mergeResults(List<ArrayList<ArrayList<IqmDataBox>>> allResults)
Merge all results to a list of 4
ArrayLists. |
protected void |
process(List<Object> chunks)
This method is called by the EventDispatcherThread, when
publish() is called within the doInBackground()
method. |
List<ArrayList<IqmDataBox>> |
processExplicit()
This method returns an object that can be cast to any other class.
|
void |
setnThreads(int nThreads) |
getChildTask, getOperator, getOperatorGUI, getParentTask, getWorkPackage, isHeadless, isVirtual, setChildTask, setHeadless, setOperator, setOperatorGUI, setParentTask, setVirtual, setWorkPackageaddPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, publish, removePropertyChangeListener, run, setProgressprivate Class<?> caller
private static final org.apache.log4j.Logger logger
private List<ArrayList<ArrayList<IqmDataBox>>> allResultLists
private int nStackItems
private ExecutorService service
private int nThreads
private int nItemsProcessed
public ExecutorServiceProcessingTask(IWorkPackage wp, boolean virtual, int nThreads)
public ExecutorServiceProcessingTask(IWorkPackage wp, boolean virtual, IOperatorGUI opGUI, int nThreads)
public ExecutorServiceProcessingTask()
protected List<ArrayList<IqmDataBox>> doInBackground() throws Exception
AbstractProcessingTaskdoInBackground in class AbstractProcessingTaskget().Exceptionprotected void done()
AbstractProcessingTaskdoInBackground() method and
must be implemented by all subclasses. It is called too, when the
SwingWorker is cancelled.done in class AbstractProcessingTaskprotected void process(List<Object> chunks)
AbstractProcessingTaskpublish() is called within the doInBackground()
method.process in class AbstractProcessingTaskchunks - - the objects to processpublic int getNItemsProcessed()
public void increaseNItemsProcessed()
public void decreaseNItemsProcessed()
public int getnThreads()
public void setnThreads(int nThreads)
nThreads - the nThreads to setprivate List<ArrayList<ArrayList<IqmDataBox>>> executeDefaultRoutine() throws Exception
The number of processed elements is equal to the number of source elements.
Exception - if anything goes wrong during processingprivate List<ArrayList<ArrayList<IqmDataBox>>> executeMultiStackEvenRoutine() throws Exception
The number of processed elements is equal to the number of source elements, but the items are about to be combined pairwise. Each pair consists of parallel items in the left and right manager list, respectively. The first source item at index 0 is taken from the currently selected manager, and the corresponding second item is taken from the opposite manager list.
For instance: [left_0, right_0] --> new_0,
[left_1, right_1] --> new_1, and so forth.
Exception - if anything goes wrong during processingprivate List<ArrayList<ArrayList<IqmDataBox>>> executeMultiStackOddRoutine() throws Exception
The number of processed elements is equal to the number of source elements, but the items are about to be combined pairwise. Each pair consists of one item in the left and right manager list, respectively. The stack is processed using the single item for each calculation.
The first source item at index 0 is taken from the currently selected manager, and the corresponding second item is taken from the opposite manager list.
For instance: [left_0, right_0] --> new_0,
[left_1, right_0] --> new_1,
[left_2, right_0] --> new_2, and so forth.
Exception - if anything goes wrong during processingprotected List<ArrayList<IqmDataBox>> mergeResults(List<ArrayList<ArrayList<IqmDataBox>>> allResults) throws Exception
ArrayLists.
The following list gives an overview of the indices and their content:
For example: an operator produces 3 images only and there is a stack of 2 sources to be processed. The list at index 1 will contain the following images in order:
images[0] = source0_image0 images[1] = source0_image1 images[2] = source0_image2 images[3] = source1_image0 images[4] = source1_image1 images[5] = source1_image2
allResults - all results from parallel processingException - if anything goes wrongprivate ArrayList<ArrayList<IqmDataBox>> addResultsToList(Result singleResult, ArrayList<ArrayList<IqmDataBox>> resultList, File virtDir) throws Exception
The resultList will contain image results in sequential order at
protected File createVirtDir()
public List<ArrayList<IqmDataBox>> processExplicit() throws Exception
IExplicitProcessingTaskIResult, others use some kind
of List interface as container.processExplicit in interface IExplicitProcessingTaskObjectExceptionCopyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.