org.omegahat.Environment.Interpreter
Class TaskQueueEvaluator

java.lang.Object
  |
  +--org.omegahat.Environment.Interpreter.BasicEvaluator
        |
        +--org.omegahat.Environment.Interpreter.UtilityEvaluator
              |
              +--org.omegahat.Environment.Interpreter.UserClassEvaluator
                    |
                    +--org.omegahat.Environment.Interpreter.TaskQueueEvaluator
All Implemented Interfaces:
DatabaseCustomer, Evaluator, ManagedEvaluatorInt, java.lang.Runnable, java.io.Serializable

public class TaskQueueEvaluator
extends UserClassEvaluator
implements java.lang.Runnable

An early and untested version of an evaluator that works by processing elements in its TaskQueue rather than being signalled using the InputConsumer listener mechanism as in the regular evaluator classes. Instead, other objects add Task objects to the queue and have these evaluated in the background. This will normally be used in a dedicated thread with other activities being carried on in other threads that communicate with this evaluator by inserting Tasks into its queue. This is very similar to the classes in TaskManager and DistributedTaskManager

See Also:
Serialized Form

Field Summary
protected  TaskQueue queue
          The queue to which new Tasks are added by other objects (potentially running in different threads) and which this evaluator monitors processing the tasks as it becomes idle and tasks are available.
protected  boolean terminate
          A flag used to allow another object to indicate that the evaluator should not process any more tasks on its queue.
 
Fields inherited from class org.omegahat.Environment.Interpreter.UserClassEvaluator
classManager
 
Fields inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
allowUnrestrictedAccess, class_lists, currentExpression, data, databases, debugger, DefaultAttachIndex, defaultDatabase, dynamicClassLoader, errorHandler, evaluationEvent, evaluationListeners, initialized, internalFunctionTables, internalPrimitiveClassNames, internalPrimitiveClassTable, lexer, localClasses, manager, options, output, parser, primitive_classes, primitiveClasses, PrimitiveClassNames, primitiveTypeNames, primitiveTypes, reversePrimitiveTypes, ShowMultipleClasses, sourceStack, stderr, stdout, SubEvaluationListeners, taskHistory, toplevelExpression, warningMessages
 
Fields inherited from interface org.omegahat.Environment.Interpreter.Evaluator
ThisVariableName
 
Constructor Summary
TaskQueueEvaluator()
           
TaskQueueEvaluator(Evaluator parent)
           
TaskQueueEvaluator(EvaluatorManager manager)
           
TaskQueueEvaluator(Options opts)
           
 
Method Summary
 Task addTask(ExpressionInt expression)
          Add an expression to the evaluator's task queue by constructing a new Task to contain it.
 Task addTask(Task task)
          Add a task to the queue.
 void run()
          This is the method that causes the evaluator to start processing the tasks on its queue or wait for new ones to be added.
 boolean terminate()
          Determine whether the evaluator should quit from processing any further tasks from the queue.
 boolean terminate(boolean val)
          Set the terminatation flag, signalling that the evaluator should not process any further tasks on its queue.
 
Methods inherited from class org.omegahat.Environment.Interpreter.UserClassEvaluator
addMethod, classManager, classManager, createInstance, createInstance, createInstance, defineClass, defineClass, defineClass, defineClass, defineClass, defineClass, DefineUserClass, DefineUserClass, DefineUserClass, findUserClass, findUserClass, parseClass, parser
 
Methods inherited from class org.omegahat.Environment.Interpreter.UtilityEvaluator
evaluator, exec, exec, findFile, getEvaluator, setProperty, setProperty
 
Methods inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
addEvaluationListener, addFunctionTable, addFunctionTable, addSourceInput, addToHistory, allowUnrestrictedAccess, allowUnrestrictedAccess, asObject, asObject, asObject, asObjectName, asPrimitiveClass, assign, assign, assign, asWriter, attach, attach, attach, attach, attach, attach, attach, classInit, classLists, classLists, classPath, classPath, commandLine, convertPrimitive, copy, copy, copyByConstructor, copyBySerialization, createClassLists, currentExpression, currentExpression, data, data, database, database, database, Debug, Debug, Debug, Debug, Debug, debugger, debugger, defaultDatabase, defaultDatabase, defaultDatabase, defaultErrorHandler, detach, detach, displayTask, displayTask, displayWarnings, displayWarnings, dynamicClassLoader, dynamicClassLoader, endSource, endSource, endSource, endTaskEvaluation, error, error, errorHandler, errorHandler, evaluate, evaluate, evaluate, evaluate, evaluationError, evaluationListeners, evaluationListeners, evaluationListeners, exists, exit, exit, expandClassName, expandedClassPathElement, find, findAsField, findClass, findClass, findClass, findClass, findFunction, findFunctionOrMethod, functionTableList, get, get, get, get, get, get, get, get, get, getBaseURL, getEvaluationEvent, getEvaluationListeners, getField, getSubEvaluationListeners, help, Import, Import, Import, init, initialize, initTaskEvaluation, internalFunctionTables, isPrimitive, isPrimitive, javaVersion, lexer, lexer, lexer, localClasses, localClasses, manager, manager, newDatabase, newDatabase, notifyListeners, notifyListeners, objects, objects, objects, options, options, output, output, output, parse, parse, parse, parse, primitiveClass, q, q, remove, remove, remove, removeFunctionTable, same, searchForClass, searchPath, searchPath, searchPath, searchPath, setEvaluationEvent, setEvaluationListeners, setSubEvaluationListeners, show, show, show, source, source, source, source, source, source, source, source, source, sourceStack, stderr, stderr, stdout, stdout, taskHistory, taskHistory, toplevelExpression, toplevelExpression, useLazyEvaluation, warning, warning, warning, warnings, warnings, where, which, which
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected TaskQueue queue
The queue to which new Tasks are added by other objects (potentially running in different threads) and which this evaluator monitors processing the tasks as it becomes idle and tasks are available.

terminate

protected boolean terminate
A flag used to allow another object to indicate that the evaluator should not process any more tasks on its queue.
Constructor Detail

TaskQueueEvaluator

public TaskQueueEvaluator()

TaskQueueEvaluator

public TaskQueueEvaluator(Options opts)

TaskQueueEvaluator

public TaskQueueEvaluator(Evaluator parent)

TaskQueueEvaluator

public TaskQueueEvaluator(EvaluatorManager manager)
Method Detail

addTask

public Task addTask(Task task)
Add a task to the queue. This is synchronized so as to avoid concurrent access. For this reason, this should be used rather than adding the Task object directly to the TaskQueue obtained via taskQueue().

addTask

public Task addTask(ExpressionInt expression)
Add an expression to the evaluator's task queue by constructing a new Task to contain it.

run

public void run()
This is the method that causes the evaluator to start processing the tasks on its queue or wait for new ones to be added. This terminates only when the appropriate flag is raised using the terminate() method. This is the method that is run when the object is handed to a Thread.
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class BasicEvaluator
Following copied from class: org.omegahat.Environment.Interpreter.BasicEvaluator
See Also:
TaskQueueEvaluator, TaskQueue

terminate

public boolean terminate()
Determine whether the evaluator should quit from processing any further tasks from the queue. This does not cause the currently active task to be interrupted.

terminate

public boolean terminate(boolean val)
Set the terminatation flag, signalling that the evaluator should not process any further tasks on its queue. It may leave these tasks to be evaluated later.