All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.sandia.cognition.framework.concurrent.MultithreadedCognitiveModelFactory Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                MultithreadedCognitiveModelFactory.java
 * Authors:             Zachary Benz
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Framework Lite
 * 
 * Copyright Jan 9, 2008, Sandia Corporation.  Under the terms of Contract 
 * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by 
 * or on behalf of the U.S. Government. Export of this program may require a 
 * license from the United States Government. See CopyrightHistory.txt for
 * complete details.
 *
 * 
 */
 
package gov.sandia.cognition.framework.concurrent;

import gov.sandia.cognition.framework.AbstractCognitiveModelFactory;

/**
 * This class defines a CognitiveModelFactory for creating 
 * MultithreadedCognitiveModel objects.
 *
 * @author Zachary Benz
 * @since 2.0
 */
public class MultithreadedCognitiveModelFactory
    extends AbstractCognitiveModelFactory
{
    /** Number of threads to use in the thread pool */
    private int numThreadsInPool;
    
    /** 
     * Creates a new instance of MultithreadedCognitiveModelFactory.
     * 
     * @param numThreadsInPool Number of threads to use in the thread pool
     */
    public MultithreadedCognitiveModelFactory(
        final int numThreadsInPool)
    {
        super();
        
        this.setNumThreadsInPool(numThreadsInPool);
    }
    
    /**
     * Creates a MultithreadedCognitiveModel using the CognitiveModuleFactories
     * that are part of the model factory.
     *
     * @return A new MultithreadedCognitiveModel using the module factories on
     *         this factory
     */
    public MultithreadedCognitiveModel createModel()
    {
        return new MultithreadedCognitiveModel(this.getNumThreadsInPool(),
            this.getModuleFactories());
    }

    /**
     * Returns the number of threads to use in the thread pool
     * 
     * @return Number of threads to use in thread pool
     */
    private int getNumThreadsInPool()
    {
        return numThreadsInPool;
    }

    /**
     * Sets the number of threads to use in the thread pool
     * 
     * @param numThreadsInPool Number of threads to use in thread pool
     */
    private void setNumThreadsInPool(int numThreadsInPool)
    {
        this.numThreadsInPool = numThreadsInPool;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy