de.grogra.rgg
Class ConcurrentTasks

java.lang.Object
  extended by de.grogra.task.Task
      extended by de.grogra.rgg.ConcurrentTasks

public final class ConcurrentTasks
extends Task

This class implements a list of ConcurrentTasks. The individual tasks are added via add(ConcurrentTask) and executed via solve().

It is assumed that the only effect of the individual concurrent tasks is to fill the queues of their current extent (see Graph.getQueues()). The queues are collected and, after all tasks have been processed, are applied as last action of the solve() method.

Author:
Ole Kniemeyer

Constructor Summary
ConcurrentTasks()
           
 
Method Summary
 void add(ConcurrentTask task)
          Adds a task to be solved during solve().
protected  void dispose(PartialTask task)
          This method is invoked when an active solver is removed or invokes Task.partialTaskDone(Solver) in order to tell this task that the partial task of the solver is no longer processed.
protected  boolean done()
          Returns true iff the complete task has been solved.
protected  void finishSolve()
           
protected  PartialTask nextPartialTask(int solverIndex)
          This method returns the next partial task for this task.
protected  void prepareSolve()
           
 void setLocalSolverCount(int count)
          Sets the number of local solvers (same virtual machine) to use.
 void solve()
           
 
Methods inherited from class de.grogra.task.Task
addSolver, getSolverCount, getSolvers, isSolving, isStopped, partialTaskDone, removeSolver, removeSolvers, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentTasks

public ConcurrentTasks()
Method Detail

add

public void add(ConcurrentTask task)
Adds a task to be solved during solve().

Parameters:
task - single task to solve

dispose

protected void dispose(PartialTask task)
Description copied from class: Task
This method is invoked when an active solver is removed or invokes Task.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.

Specified by:
dispose in class Task
Parameters:
task - partial task which is no longer processed

done

protected boolean done()
Description copied from class: Task
Returns true iff the complete task has been solved.

Specified by:
done in class Task
Returns:
has the task been solved?

finishSolve

protected void finishSolve()
Overrides:
finishSolve in class Task

nextPartialTask

protected PartialTask nextPartialTask(int solverIndex)
Description copied from class: Task
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.

Specified by:
nextPartialTask in class Task
Parameters:
solverIndex - index of solver which will be used for next task
Returns:
next partial task, or null

prepareSolve

protected void prepareSolve()
Overrides:
prepareSolve in class Task

setLocalSolverCount

public void setLocalSolverCount(int count)
Sets the number of local solvers (same virtual machine) to use. The default value is the number of processors which are available to the virtual machine.

Parameters:
count - number of local solvers to use

solve

public void solve()
Overrides:
solve in class Task