gov.sandia.cognition.framework.concurrent
Class MultithreadedCognitiveModel

java.lang.Object
  extended by gov.sandia.cognition.framework.AbstractCognitiveModel
      extended by gov.sandia.cognition.framework.lite.AbstractCognitiveModelLite
          extended by gov.sandia.cognition.framework.concurrent.MultithreadedCognitiveModel
All Implemented Interfaces:
CognitiveModel, Serializable

public class MultithreadedCognitiveModel
extends AbstractCognitiveModelLite

This class provides a multithreaded implementation of the CognitiveModel interface. The implementation is lite, in that modules cannot be dynamically added or removed from the model. Multihtreading is employed at the level of the evaluation of modules during an update call. During update, each module sequentially performs a readState in preparation for evaluation, and then evaluation of the modules is performed concurrently using a threadpool. The change in state of each module is written out sequentially following the completion of all module evaluations.

Since:
2.0
Author:
Zachary Benz
See Also:
Serialized Form

Nested Class Summary
protected static class MultithreadedCognitiveModel.ModuleEvaluator
          Implements a Callable class for executing the evaluation of a CognitiveModule on a thread
 
Field Summary
 
Fields inherited from class gov.sandia.cognition.framework.lite.AbstractCognitiveModelLite
numModules, state
 
Constructor Summary
MultithreadedCognitiveModel(int numThreadsInPool, CognitiveModuleFactory... moduleFactories)
          Creates a new instance of MultithreadedCognitiveModel.
MultithreadedCognitiveModel(int numThreadsInPool, Iterable<? extends CognitiveModuleFactory> moduleFactories)
          Creates a new instance of MultithreadedCognitiveModel.
 
Method Summary
 List<ConcurrentCognitiveModule> getModules()
          Gets the modules in the model.
 void update(CognitiveModelInput input)
          Updates the state of the model from the new input.
 
Methods inherited from class gov.sandia.cognition.framework.lite.AbstractCognitiveModelLite
getCurrentState, getSemanticIdentifierMap, initializeCognitiveState, resetCognitiveState, setCognitiveState, setSemanticIdentifierMap
 
Methods inherited from class gov.sandia.cognition.framework.AbstractCognitiveModel
addCognitiveModelListener, fireModelStateChangedEvent, fireModelStateChangedEvent, getModelListeners, removeCognitiveModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultithreadedCognitiveModel

public MultithreadedCognitiveModel(int numThreadsInPool,
                                   CognitiveModuleFactory... moduleFactories)
Creates a new instance of MultithreadedCognitiveModel. It instantiates new CognitiveModules from all of the given CognitiveModuleFactories

Parameters:
numThreadsInPool - Number of threads to use in thread pool
moduleFactories - The CognitiveModuleFactories used to create the CognitiveModules for this model

MultithreadedCognitiveModel

public MultithreadedCognitiveModel(int numThreadsInPool,
                                   Iterable<? extends CognitiveModuleFactory> moduleFactories)
Creates a new instance of MultithreadedCognitiveModel. It instantiates new CognitiveModules from all of the given CognitiveModuleFactories

Parameters:
numThreadsInPool - Number of threads to use in thread pool
moduleFactories - The CognitiveModuleFactories used to create the CognitiveModules for this model
Method Detail

update

public void update(CognitiveModelInput input)
Updates the state of the model from the new input.

Parameters:
input - The input to the model.

getModules

public List<ConcurrentCognitiveModule> getModules()
Gets the modules in the model.

Returns:
The modulese that are part of the model.