Prism.conn.basic
Class FIFODispatch

java.lang.Object
  |
  +--Prism.conn.basic.FIFODispatch
All Implemented Interfaces:
IDispatch

public class FIFODispatch
extends java.lang.Object
implements IDispatch

A simple FIFO based message store which allows a dynamic set of queue to be handled in the architecture. Messages are always added to the end of the queue whereas they are removed at the head of the queue. There is no knowledge of priorities, although that can be created by internally organizing the queue separately.

Version:
0.1
Author:
Nikunj Mehta

Constructor Summary
FIFODispatch()
          Create the message store with DEFAULT_SIZE elements
FIFODispatch(int FIFOSize)
          Create the message store
 
Method Summary
 void add(Message m)
          Add a message to the beginning of the queue.
 Message getMessage()
          Get a message from the head of the queue and remove it from the message store, although the message object itself is not deleted.
 int getWaitingLength()
          Get the number of queued messages waiting to be dispatched
 void setMessageCapacity(int n)
          Set the capacity of messages that can be stored before being dispatched
 java.lang.String toString()
          Get a string representation of the message queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FIFODispatch

public FIFODispatch()
Create the message store with DEFAULT_SIZE elements
See Also:
C3.conn.FIFODispatch#DEFAULT_SIZE

FIFODispatch

public FIFODispatch(int FIFOSize)
Create the message store
Method Detail

add

public void add(Message m)
Add a message to the beginning of the queue. The method is synchronized so that simultaneous additions and removals are not possible. This is a potential major bottleneck.
Specified by:
add in interface IDispatch
Parameters:
m - Message of either a Request or Notification type

getMessage

public Message getMessage()
Get a message from the head of the queue and remove it from the message store, although the message object itself is not deleted.
Specified by:
getMessage in interface IDispatch
Returns:
Message The message object at the head of the FIFO

getWaitingLength

public int getWaitingLength()
Get the number of queued messages waiting to be dispatched
Specified by:
getWaitingLength in interface IDispatch
Returns:
int Number of queue remaining

toString

public java.lang.String toString()
Get a string representation of the message queue. This is used primarily for debugging
Overrides:
toString in class java.lang.Object
Returns:
String The stringified representation of the queue.

setMessageCapacity

public void setMessageCapacity(int n)
Set the capacity of messages that can be stored before being dispatched
Specified by:
setMessageCapacity in interface IDispatch
Parameters:
n - int the required capacity of the message store