Class ParallelPoolProcessing
- java.lang.Object
-
- de.uni_trier.wi2.procake.utils.concurrent.ParallelPoolProcessing
-
public class ParallelPoolProcessing extends Object
This class is intended to be used to process elements of a case base in parallel across multiple threads. Therefore, it is specified by the using class which task should be executed on every element of the case base.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceParallelPoolProcessing.ProcessingTaskInterface that holds the main method for every call to process an element from the case base.
-
Constructor Summary
Constructors Constructor Description ParallelPoolProcessing()ParallelPoolProcessing(DataObject[] poolArr, int taskSize, boolean sortQueue)ParallelPoolProcessing(ReadableObjectPool<DataObject> pool, int taskSize, boolean sortQueue)ParallelPoolProcessing(ReadableObjectPool<DataObject> pool, int taskSize, boolean sortQueue, int numberOfWorkers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProcessingTask(ParallelPoolProcessing.ProcessingTask task)intgetNumberOfWorkers()intgetTaskSize()booleanisSorting()voidprocess()Main method that is called in order to start parallel processing of all cases in the case base.voidprocessAndWait()Main method that is called in order to start parallel processing of all cases in the case base.voidsetSorting(boolean sorting)voidsetTaskSize(int taskSize)voidterminate()Terminates all computations of the underlying thread pool.
-
-
-
Constructor Detail
-
ParallelPoolProcessing
public ParallelPoolProcessing()
-
ParallelPoolProcessing
public ParallelPoolProcessing(ReadableObjectPool<DataObject> pool, int taskSize, boolean sortQueue)
-
ParallelPoolProcessing
public ParallelPoolProcessing(ReadableObjectPool<DataObject> pool, int taskSize, boolean sortQueue, int numberOfWorkers)
-
ParallelPoolProcessing
public ParallelPoolProcessing(DataObject[] poolArr, int taskSize, boolean sortQueue)
-
-
Method Detail
-
processAndWait
public void processAndWait()
Main method that is called in order to start parallel processing of all cases in the case base. It starts all workers. The method does block the main thread. It is not required to callterminate()to finish all computations of the thread pool.
-
terminate
public void terminate()
Terminates all computations of the underlying thread pool. This methof has to be called after a prior call ofprocess(). In contrast,processAndWait()automatically blocks until all computations have finished.
-
process
public void process()
Main method that is called in order to start parallel processing of all cases in the case base. It starts all workers. The method does not block the main thread. It is required to callterminate()at a certain point to finish all computations of the thread pool.
-
getTaskSize
public int getTaskSize()
-
setTaskSize
public void setTaskSize(int taskSize)
-
isSorting
public boolean isSorting()
-
setSorting
public void setSorting(boolean sorting)
-
getNumberOfWorkers
public int getNumberOfWorkers()
-
addProcessingTask
public void addProcessingTask(ParallelPoolProcessing.ProcessingTask task)
-
-