Module raytracer

Class Task

java.lang.Object
de.grogra.task.Task
Direct Known Subclasses:
ConcurrentTasks, PixelwiseRenderer, PTaskManager

public abstract class Task extends Object
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 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 returns true iff the method stop() has been invoked on this task.
      Returns:
      has this task been stopped?
    • addSolver

      public void addSolver(Solver s)
      Adds a solver to this task.
      Parameters:
      s - a solver
    • removeSolver

      public void removeSolver(Solver s)
      Removes a solver from this task. The method Solver.dispose() is invoked on s.
      Parameters:
      s - a solver
    • getSolverCount

      public int getSolverCount()
      Returns the number of solvers for this task.
      Returns:
      number of solvers
    • nextPartialTask

      protected abstract PartialTask nextPartialTask(int solverIndex)
      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

      protected abstract void dispose(PartialTask task)
      This method is invoked when an active solver is removed or invokes partialTaskDone(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

      public void partialTaskDone(Solver s)
      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 of Task) 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 of nextPartialTask(int).
      Parameters:
      s - the solver which has completed processing its partial task
    • done

      protected abstract boolean done()
      Returns true 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

      public Solver[] getSolvers()
    • removeSolvers

      public void removeSolvers()