pivot.util.concurrent
Class Dispatcher

java.lang.Object
  extended by pivot.util.concurrent.Dispatcher

public class Dispatcher
extends Object

Operates a thread pool for dispatching runnable tasks. Runnables are added to a pending queue and dispatched as threads become available to execute them.

TODO This class is currently functional but not complete. Runnables are currently dispatched as soon as they are added to the queue. Need to complete the pooling implementation.

TODO Add a flag that allows the monitor thread to run as a non-daemon, and define a shutdown() or cancel() method that will stop the thread. This will allow ApplicationContext to control the dispatcher lifecycle and prevent the thread from being randomly killed by applets.

TODO Is there a way to throw an AbortException when an item is removed from the queue, without having to rely on methods like abort()?

Author:
gbrown, tvolkert

Constructor Summary
Dispatcher()
           
Dispatcher(int minimumThreadCount, int maximumThreadCount)
           
 
Method Summary
 Queue<Runnable> getPendingQueue()
          Returns a reference to the dispatcher's pending runnable queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dispatcher

public Dispatcher()

Dispatcher

public Dispatcher(int minimumThreadCount,
                  int maximumThreadCount)
Method Detail

getPendingQueue

public Queue<Runnable> getPendingQueue()
Returns a reference to the dispatcher's pending runnable queue.

Returns:
A synchronized queue from which the dispatcher will withdraw runnables.