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 PartialTasks. These
partial tasks are solved synchronously or asynchronously by a set of
Solvers which may work in different threads or even
on remote computers.- Author:
- Ole Kniemeyer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a solver to this task.protected abstract voiddispose(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 booleandone()Returnstrueiff the complete task has been solved.protected voidintReturns the number of solvers for this task.Solver[]booleanbooleanThis method returnstrueiff the methodstop()has been invoked on this task.protected abstract PartialTasknextPartialTask(int solverIndex) This method returns the next partial task for this task.voidThis method has to be invoked by a solver if it has completed processing its current partial task.protected voidvoidRemoves a solver from this task.voidvoidsolve()voidstop()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 returnstrueiff 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,nullis 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()Returnstrueiff 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()
-