Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.search.api.SearchWorkerThread.java

Here you can find all the information about the file org.dgpf.search.api.SearchWorkerThread.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-03-31 09:00:46
 * Original Filename: org.dgpf.search.api.SearchWorkerThread.java
 * Version          : 2.1.2
 * Last modification: 2006-07-15
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.dgpf.search.api;

import java.io.Serializable;


/**
 * The search worker thread performs the work of search by extracting tasks
 * from a search task queue and executing them in an own context.
 *
 * @param <Genotype>    The sort of genotype used to represent individuals.
 *                      This must be a serializable type.
 *
 * @author Thomas Weise
 */

public final  class   SearchWorkerThread<Genotype extends Serializable>
              extends SearchTaskThread<Genotype>
  {
/**
 * The internally used search context.
 */

  private final SearchContext<Genotype> m_context ;
  
  
/**
 * Create a new search worker thread.
 * @param p_se  The search engine to work for.
 * @param p_queue   The search task queue to use. This must not be
 *                  <code>null</code>.
 * @param p_context The search context to be used by the worker thread.
 *                  This must not be <code>null</code>. 
 */

  public  SearchWorkerThread (final SearchEngine<Genotype>      p_se,
                              final SearchTaskQueue<Genotype>   p_queue,
                              final SearchContext<Genotype>     p_context)
    {
    super(p_se, p_queue);
    this.m_context = p_context;
    }
  


/**
 * This method will be called whenever a new search task becomes available.
 * @param p_task  The search task that just became available.
 */

  @Override
  protected final void  process (final SearchTask<Genotype> p_task)
    {
    p_task.execute(this.m_context);
    }
  
/**
 * This method is called by <code>abort()</code> to perform some work before
 * halting the thread.
 * @see #abort()
 */

  @Override
  protected void  do_abort()
    {
    this.m_context.abort();
    super.do_abort();
    }
  
/**
 * Override this method to perform something when the thread dies.
 */

  @Override
  protected void  after_termination ()
    {
    this.m_context.abort();
    super.after_termination();
    }
  
/**
 * <p>
 * Update the search context used by this worker.
 * </p><p><i>Warning:</i>
 * This method is not synchronized, you must ensure that the thread is not
 * currently processing anything. </p>
 * @param p_data  The simulation data to update with. This can be any
 *                instance <code>SearchDefinition</code>,
 *                <code>SearchState</code> or <code>SearchParameters</code>.
 */

  public  final void  update_context  (final Object p_data)
    {
    this.m_context.assign(p_data);
    }
  
  

/**
 * Obtain the name of the thread.
 * @return  A human readable name of the sfc thread.
 */

  @Override
  public   String  toString()
    {
    return "Search Worker Thread (" + this.getThreadGroup() + ')';
    }
  }

File Information:

file name:SearchWorkerThread.java
package:org.dgpf.search.api
qualified name:org.dgpf.search.api.SearchWorkerThread.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/search/api/SearchWorkerThread.java
size:3.809 KB (3901 B)
uploaded: 2015-07-22 04:11:00 GMT+0000
last update: 2006-07-15 09:37:16 GMT+0000
last access: 2017-11-18 23:21:51 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-18 23:21:51 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo