java.lang.Object
de.grogra.task.Task
- Direct Known Subclasses:
ConcurrentTasks
,PixelwiseRenderer
,PTaskManager
A
Task
is used for a complex problem which can be decomposed
in several independent PartialTask
s. These
partial tasks are solved synchronously or asynchronously by a set of
Solver
s which may work in different threads or even
on remote computers.- Author:
- Ole Kniemeyer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a solver to this task.protected abstract void
dispose
(PartialTask task) This method is invoked when an active solver is removed or invokespartialTaskDone(Solver)
in order to tell this task that the partial task of the solver is no longer processed.protected abstract boolean
done()
Returnstrue
iff the complete task has been solved.protected void
int
Returns the number of solvers for this task.Solver[]
boolean
boolean
This method returnstrue
iff the methodstop()
has been invoked on this task.protected abstract PartialTask
nextPartialTask
(int solverIndex) This method returns the next partial task for this task.void
This method has to be invoked by a solver if it has completed processing its current partial task.protected void
void
Removes a solver from this task.void
void
solve()
void
stop()
This method is invoked in order to stop the computation of this task.
-
Constructor Details
-
Task
public Task()
-
-
Method Details
-
stop
public void stop()This method is invoked in order to stop the computation of this task. -
isStopped
public boolean isStopped()This method returnstrue
iff the methodstop()
has been invoked on this task.- Returns:
- has this task been stopped?
-
addSolver
Adds a solver to this task.- Parameters:
s
- a solver
-
removeSolver
Removes a solver from this task. The methodSolver.dispose()
is invoked ons
.- Parameters:
s
- a solver
-
getSolverCount
public int getSolverCount()Returns the number of solvers for this task.- Returns:
- number of solvers
-
nextPartialTask
This method returns the next partial task for this task. If all parts of the task have been solved or currently are being solved,null
is returned. However, a later invocation may return a partial task if a currently active solver does not completely solve its partial task.- Parameters:
solverIndex
- index of solver which will be used for next task- Returns:
- next partial task, or
null
-
dispose
This method is invoked when an active solver is removed or invokespartialTaskDone(Solver)
in order to tell this task that the partial task of the solver is no longer processed. Note that the solver may not have completely processed its partial task.- Parameters:
task
- partial task which is no longer processed
-
partialTaskDone
This method has to be invoked by a solver if it has completed processing its current partial task. Note that (depending on the specific implementation ofTask
) a solver may complete processing its partial task without completely solving it. In this case the unsolved part of the partial task is returned as part of later invocations ofnextPartialTask(int)
.- Parameters:
s
- the solver which has completed processing its partial task
-
done
protected abstract boolean done()Returnstrue
iff the complete task has been solved.- Returns:
- has the task been solved?
-
isSolving
public boolean isSolving() -
solve
public void solve() -
prepareSolve
protected void prepareSolve() -
finishSolve
protected void finishSolve() -
getSolvers
-
removeSolvers
public void removeSolvers()
-