simnet
Class RoundRobin

java.lang.Object
  extended bysimnet.LinkProcessor
      extended bysimnet.RoundRobin
All Implemented Interfaces:
Pluggable, PlugoutListener

public class RoundRobin
extends LinkProcessor
implements Pluggable

A link processor that checks links sequentially for available frames. To make RoundRobin work we must do the following: 1. iterate through Links and if a frame is found return it 2. each time the Link Processor is called (with getFrame) it must start cycling from where it left off the previous time. Neither the Enumeration nor the Iterator classes allow us to do anything like that so we use an array and keep state instead. To use the array we have to copy all the Links from the Link table to a link array. We can' t do it when the RoundRobin object is instantiated because at that time the link table is empty (it gets filled as Links get created) so we need to do the copying only once all the links are present in the Link Table. The only time at which this is garanteed is when getFrame() is called. So we have to do the copying the first time getFrame() is called.


Field Summary
(package private)  Link[] link_array
          An array containing all the Node' s Links
(package private)  java.util.Hashtable links
          The link table that holds all the Node' s Links
private  int mark
          A variable that keeps track of where the RoundRobin processor left off
private  boolean rebuild
          Keeps track of whether the Link array has been built or not
 
Fields inherited from class simnet.LinkProcessor
NODE_ID, parent_node
 
Constructor Summary
RoundRobin()
           
 
Method Summary
 Frame getFrame()
          Returns a Frame from one of the Node' s Links
 void initialize(java.util.Hashtable link_table, Node parent)
          Initializes a new RoundRobin link processor by initializing its link_table and node fields.
 boolean prePlugout(java.lang.Object replacement)
          Nothing special for replacing, clean up some memory when removing.
 void rebuild()
          Constructs the Link Array
 
Methods inherited from class simnet.LinkProcessor
finalize, plugoutNotification
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

links

java.util.Hashtable links
The link table that holds all the Node' s Links


link_array

Link[] link_array
An array containing all the Node' s Links


mark

private int mark
A variable that keeps track of where the RoundRobin processor left off


rebuild

private boolean rebuild
Keeps track of whether the Link array has been built or not

Constructor Detail

RoundRobin

public RoundRobin()
Method Detail

initialize

public void initialize(java.util.Hashtable link_table,
                       Node parent)
Initializes a new RoundRobin link processor by initializing its link_table and node fields.

Overrides:
initialize in class LinkProcessor
Parameters:
link_table - the owner' s (Node) Link table
parent - the Node that owns this LinkProcessor

rebuild

public void rebuild()
Constructs the Link Array


getFrame

public Frame getFrame()
Returns a Frame from one of the Node' s Links

Specified by:
getFrame in class LinkProcessor
Returns:
a Frame

prePlugout

public boolean prePlugout(java.lang.Object replacement)
Nothing special for replacing, clean up some memory when removing.

Specified by:
prePlugout in interface Pluggable
Returns:
if this object can now be removed (was the operation sucessful)