org.encog.util.concurrency.job
Class ConcurrentJob

java.lang.Object
  extended by org.encog.util.concurrency.job.ConcurrentJob
All Implemented Interfaces:
Runnable, MultiThreadable
Direct Known Subclasses:
PruneIncremental

public abstract class ConcurrentJob
extends Object
implements Runnable, MultiThreadable

This class forms the basis for a job that can be run concurrently.


Constructor Summary
ConcurrentJob(StatusReportable report)
          Construct a concurrent job.
 
Method Summary
 boolean getShouldStop()
           
 int getThreadCount()
          
 boolean isRunning()
           
abstract  int loadWorkload()
          Load the subtasks.
abstract  void performJobUnit(JobUnitContext context)
          Perform one job unit.
 void process()
          Process the job.
 void processBackground()
           
 void reportStatus(JobUnitContext context, String status)
          Report the status for this job.
abstract  Object requestNextTask()
          Request the next task to be processed.
 void run()
           
 void setReport(StatusReportable r)
           
 void setThreadCount(int numThreads)
          Set the number of threads to use.
 void stop()
          Request the process to stop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentJob

public ConcurrentJob(StatusReportable report)
Construct a concurrent job.

Parameters:
report - The object to report status to.
Method Detail

loadWorkload

public abstract int loadWorkload()
Load the subtasks.

Returns:
The total number of subtasks.

performJobUnit

public abstract void performJobUnit(JobUnitContext context)
Perform one job unit.

Parameters:
context - The context for the job unit.

process

public void process()
Process the job.


processBackground

public void processBackground()

reportStatus

public void reportStatus(JobUnitContext context,
                         String status)
Report the status for this job.

Parameters:
context - The job context.
status - The status to report.

requestNextTask

public abstract Object requestNextTask()
Request the next task to be processed.

Returns:
The next task to be processed.

getShouldStop

public boolean getShouldStop()
Returns:
True if the process should stop.

stop

public void stop()
Request the process to stop.


run

public void run()
Specified by:
run in interface Runnable

isRunning

public boolean isRunning()
Returns:
the running

setReport

public void setReport(StatusReportable r)

getThreadCount

public int getThreadCount()

Specified by:
getThreadCount in interface MultiThreadable
Returns:
The number of threads to use, 0 to automatically determine based on core count.

setThreadCount

public void setThreadCount(int numThreads)
Set the number of threads to use.

Specified by:
setThreadCount in interface MultiThreadable
Parameters:
numThreads - The number of threads to use, or zero to automatically determine based on core count.


Copyright © 2014. All Rights Reserved.