fr.ifremer.isisfish.simulator.launcher
Class SimulationExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by fr.ifremer.isisfish.simulator.launcher.SimulationExecutor
All Implemented Interfaces:
Executor, ExecutorService

public class SimulationExecutor
extends ThreadPoolExecutor

Un executor qui utilise un certain type de SimulatorLauncher pour executer les jobs soumis dans la queue de SimulationService

Les fonctionnalites en plus par rapport a un ThreadPoolExecutor sont:

  • la possibilite de suspendre l'executor puis ensuite de le relancer
  • l'utilisation de beforeExecute pour fixer le SimulatorLauncher du job

    Il est aussi possible d'ecoute l'etat de l'attribut pause

    Version:
    $Revision: 3124 $ Last update : $Date: 2010-11-29 19:14:09 +0100 (Mon, 29 Nov 2010) $ By : $Author: chatellier $
    Author:
    poussin

    Nested Class Summary
     
    Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
    ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
     
    Field Summary
    protected  int lastCorePoolSize
              le nombre de thread utilise avant la pause
    protected  SimulatorLauncher launcher
              le launcher a utilise pour les simulations
    protected  boolean pause
              vrai si cet executor est en pause
    protected  PropertyChangeSupport propertyListeners
               
    protected  SimulationService simulationService
              le simulation service qui a cree cet executor
     
    Constructor Summary
    SimulationExecutor(SimulationService simulationService, SimulatorLauncher launcher, SimulationQueue workQueue)
               
     
    Method Summary
     void addPropertyChangeListener(PropertyChangeListener listener)
               
     void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
               
    protected  void beforeExecute(Thread t, Runnable r)
              Met les threads en attente si pause est vrai, et fixe le SimulatorLauncher a utiliser pour par la tache.
     SimulatorLauncher getLauncher()
               
     SimulationService getSimulationService()
               
     boolean isPause()
               
     void pause()
              demande au thread d'arreter de prendre de nouvelle tache
     void removePropertyChangeListener(PropertyChangeListener listener)
               
     void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
               
     void resume()
              indique au thread de recommencer a prendre de nouvelle tache
     void setPause(boolean pause)
              Change la valeur de la variable pause, si pause est alors vrai notifie tous les threads en attente
     
    Methods inherited from class java.util.concurrent.ThreadPoolExecutor
    afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
     
    Methods inherited from class java.util.concurrent.AbstractExecutorService
    invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
     
    Methods inherited from class java.lang.Object
    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    propertyListeners

    protected PropertyChangeSupport propertyListeners

    pause

    protected boolean pause
    vrai si cet executor est en pause


    lastCorePoolSize

    protected int lastCorePoolSize
    le nombre de thread utilise avant la pause


    simulationService

    protected SimulationService simulationService
    le simulation service qui a cree cet executor


    launcher

    protected SimulatorLauncher launcher
    le launcher a utilise pour les simulations

    Constructor Detail

    SimulationExecutor

    public SimulationExecutor(SimulationService simulationService,
                              SimulatorLauncher launcher,
                              SimulationQueue workQueue)
    Method Detail

    getSimulationService

    public SimulationService getSimulationService()

    getLauncher

    public SimulatorLauncher getLauncher()

    addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

    addPropertyChangeListener

    public void addPropertyChangeListener(String propertyName,
                                          PropertyChangeListener listener)

    removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

    removePropertyChangeListener

    public void removePropertyChangeListener(String propertyName,
                                             PropertyChangeListener listener)

    beforeExecute

    protected void beforeExecute(Thread t,
                                 Runnable r)
    Met les threads en attente si pause est vrai, et fixe le SimulatorLauncher a utiliser pour par la tache. Si la tache a deja un SimulatorLauncher d'assigne, on ne fait pas la tache

    Overrides:
    beforeExecute in class ThreadPoolExecutor
    Parameters:
    t - le thread qui va executer la tache
    r -

    isPause

    public boolean isPause()

    pause

    public void pause()
    demande au thread d'arreter de prendre de nouvelle tache


    resume

    public void resume()
    indique au thread de recommencer a prendre de nouvelle tache


    setPause

    public void setPause(boolean pause)
    Change la valeur de la variable pause, si pause est alors vrai notifie tous les threads en attente

    Parameters:
    pause - pause value to set


    Copyright © 1999-2012 CodeLutin. All Rights Reserved.