Prism.conn.basic
Class RoundRobinScheduler

java.lang.Object
  |
  +--Prism.conn.basic.RoundRobinScheduler
All Implemented Interfaces:
IScheduler

public class RoundRobinScheduler
extends java.lang.Object
implements IScheduler

The RoundRobinScheduler is an example of an architecture independent scheduling co-connector. Every architecture has a strategy for implementing multiple threads. Some may require only one whereas others need multiple threads for processing messages. In this scheduler, a pool of threads is created which then processes messages from the common shared pool. The pool of threads can be dynamically managed to match the processing needs as long as it is within the defined ranges.

Version:
0.1
Author:
Nikunj Mehta

Constructor Summary
RoundRobinScheduler(IDispatch disp)
          Create a scheduler that dispatches messages on a round robin basis with a default of DEFAULT_COUNT threads
RoundRobinScheduler(IDispatch disp, int n)
          Create a scheduler that dispatches messages on a round robin basis with the given number of threads.
RoundRobinScheduler(int n)
          Create a scheduler that dispatches messages on a round robin basis with a default of DEFAULT_COUNT threads
 
Method Summary
 int getThreadCount()
          This method returns the current count of the threads servicing the message queue.
 void setThreadCount(int n)
          This method sets the number of threads this architecture uses to service the message queue to n.
 void setTimeStep(int step)
          Set the time the thread stops before dispatching another message
 void shutdown()
          This method exits the JVM ASAP without gently killing the threads.
 void start()
          This method starts all the threads in the scheduler and allows the messages to be dispatched to the destination components.
 void stop()
          This method stops all the threads in the architecture and finally exits the JVM.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoundRobinScheduler

public RoundRobinScheduler(IDispatch disp)
Create a scheduler that dispatches messages on a round robin basis with a default of DEFAULT_COUNT threads
Parameters:
disp - IDispatch a reference to the message store.

RoundRobinScheduler

public RoundRobinScheduler(int n)
Create a scheduler that dispatches messages on a round robin basis with a default of DEFAULT_COUNT threads
Parameters:
n - int number of threads in the scheduler.

RoundRobinScheduler

public RoundRobinScheduler(IDispatch disp,
                           int n)
Create a scheduler that dispatches messages on a round robin basis with the given number of threads. The threads required should be in the range of allowable threads, otherwise a default of DEFAULT_COUNT threads are used.
Parameters:
disp - IDispatch a reference to the message store.
Method Detail

setThreadCount

public void setThreadCount(int n)
This method sets the number of threads this architecture uses to service the message queue to n. If n is less than or greater than LOWER_BOUND or UPPER_BOUND respectively then it the function does nothing and returns.
Parameters:
n - int the new number of threads to use from now.

getThreadCount

public int getThreadCount()
This method returns the current count of the threads servicing the message queue.
Returns:
int the number of threads servicing the message queue.

start

public void start()
This method starts all the threads in the scheduler and allows the messages to be dispatched to the destination components.
Specified by:
start in interface IScheduler

stop

public void stop()
This method stops all the threads in the architecture and finally exits the JVM. The threads will stop only after completeling the current threadFunction() call that they are executing. To shutdown the scheduler and system.
Specified by:
stop in interface IScheduler
See Also:
Prism.framework.Architecture#shutdown

shutdown

public void shutdown()
This method exits the JVM ASAP without gently killing the threads. To halt or pause the threads use stop(). Restart the scheduler by calling start.
Specified by:
shutdown in interface IScheduler
See Also:
Prism.framework.Architecture#stop

setTimeStep

public void setTimeStep(int step)
Set the time the thread stops before dispatching another message
Parameters:
step - int the number of milliseconds to wait