org.lsst.ccs.utilities.dispatch
Class ParallelCommandDispatcher<T>

java.lang.Object
  extended by org.lsst.ccs.utilities.dispatch.ParallelCommandDispatcher<T>
Type Parameters:
T - the nature of the code able to handle the CommandFor<T> Objects

public class ParallelCommandDispatcher<T>
extends java.lang.Object

Dispatches a Command object to registered "executants" able to handle the command; each command execution may be handled by a different Thread so every registered agent does not have to wait for termination of code from the previous call.

BEWARE :

Author:
bernard AMADE

Field Summary
protected  java.util.concurrent.CopyOnWriteArrayList<T> list
          List of all registered agent that may take action.
protected  java.util.concurrent.ExecutorService loop
          ExecutorService that deals with the Threads handling the commands.
 
Constructor Summary
ParallelCommandDispatcher()
          Creates an asynchronous Dispatcher for Commands.
ParallelCommandDispatcher(java.util.concurrent.ExecutorService execService)
          Creates an asynchronous Dispatcher for Commands: uses a specific ExecutorService.
 
Method Summary
 void addExecutant(T executant)
          adds an executant to the list of those going to execute Commands when needed.
 void dispatchCommand(CommandFor<T> command)
          Send a Command request for all registered executants.
 void removeExecutant(T executant)
          removes an executant form the list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loop

protected java.util.concurrent.ExecutorService loop
ExecutorService that deals with the Threads handling the commands.


list

protected java.util.concurrent.CopyOnWriteArrayList<T> list
List of all registered agent that may take action.

Constructor Detail

ParallelCommandDispatcher

public ParallelCommandDispatcher()
Creates an asynchronous Dispatcher for Commands. Uses the standard common ExecutorService for this package.


ParallelCommandDispatcher

public ParallelCommandDispatcher(java.util.concurrent.ExecutorService execService)
Creates an asynchronous Dispatcher for Commands: uses a specific ExecutorService.

Method Detail

addExecutant

public void addExecutant(T executant)
adds an executant to the list of those going to execute Commands when needed.

Parameters:
executant -

removeExecutant

public void removeExecutant(T executant)
removes an executant form the list

Parameters:
executant -

dispatchCommand

public void dispatchCommand(CommandFor<T> command)
Send a Command request for all registered executants.

Parameters:
command -


Copyright © 2012 LSST. All Rights Reserved.