I
- the class of a job ID for this engine.R
- the result class.public abstract class Engine<I extends Comparable<I>,R> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Engine.CalculationResult<I,R>
This is a helper class to store results of parallel computations.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NUMBER_OF_THREADS |
Constructor and Description |
---|
Engine(Class<I> identClass,
Class<R> resultClass) |
Modifier and Type | Method and Description |
---|---|
void |
addTask(I ident)
Adds the task with the given identifier to this Engine.
|
void |
addTasks(Collection<I> idents)
Adds the tasks with the given identifiers to this Engine.
|
void |
addTasks(I[] idents)
Adds the tasks with the given identifiers to this Engine.
|
void |
calculate()
Starts the actual, parallel computation.
|
void |
clearTasks()
Removes all tasks from this Engine.
|
abstract Callable<R> |
createCallable(I ident)
A method that should create a Callable (computation job) for the given
identifier object.
|
Class<I> |
getIdentClass()
Returns the class of objects to identify jobs for this Engine.
|
int |
getNumberOfThreads()
Returns the number of threads that are used for computation (16 per
default).
|
ProgressReporter |
getReporter()
Returns the ProgressReporter that is used to report progress.
|
Class<R> |
getResultClass()
Returns the class of result objects of jobs in this Engine.
|
Collection<Engine.CalculationResult<I,R>> |
getResults()
Returns the results of this Engines last computation.
|
boolean |
isCancelOnException()
Returns true if and only if this Engine stops computation if one thread
throws an exception.
|
void |
removeTask(I ident)
Removes the task with the given identifier from this Engine.
|
void |
removeTasks(Collection<I> idents)
Removes the tasks with the given identifiers from this Engine.
|
void |
removeTasks(I[] idents)
Removes the tasks with the given identifiers from this Engine.
|
void |
setCancelOnException(boolean cancelOnException)
Sets a flag that decides whether this Engine stops computation if one
thread
throws an exception.
|
void |
setNumberOfThreads(int numberOfThreads)
Sets the number of threads that are used for computation (16 per
default).
|
void |
setReporter(ProgressReporter reporter)
Sets the ProgressReporter that is used to report progress.
|
public static final int DEFAULT_NUMBER_OF_THREADS
public Class<I> getIdentClass()
public Class<R> getResultClass()
public int getNumberOfThreads()
public void setNumberOfThreads(int numberOfThreads)
numberOfThreads
- the number of threads that are used for
computation.public boolean isCancelOnException()
public void setCancelOnException(boolean cancelOnException)
cancelOnException
- true if and only if this Engine should stop
computation if one thread throws an exception.public ProgressReporter getReporter()
public void setReporter(ProgressReporter reporter)
reporter
- the ProgressReporter that is used to report progress.
This is a CommandLineProgressReporter per default. If it is set to null,
the progress is not reported.public abstract Callable<R> createCallable(I ident)
ident
- an identifier.public void addTask(I ident)
ident
- an identifier.public void addTasks(I[] idents)
idents
- some identifiers.public void addTasks(Collection<I> idents)
idents
- some identifiers.public void clearTasks()
public void removeTask(I ident)
ident
- an identifier.public void removeTasks(I[] idents)
idents
- some identifiers.public void removeTasks(Collection<I> idents)
idents
- some identifiers.public void calculate()
public Collection<Engine.CalculationResult<I,R>> getResults()
Copyright (C) 2013-2015 Benjamin Paaßen, Georg Zentgraf, AG Theoretical Computer Science, Centre of Excellence Cognitive Interaction Technology (CITEC), University of Bielefeld, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/tcs . This documentation is licensed under the conditions of CC-BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/