Class FIFOChannel<T>

java.lang.Object
io.github.sumeetk321.FIFOChannel<T>
Type Parameters:
T - a generic type which determines the data type in the channel

public class FIFOChannel<T> extends Object
This class defines the first-in-first-out channel object. It is essentially a wrapper around a Queue object, but also defines the amount of tokens that the source outputs, as well as the amount of tokens that the destination consumes to perform its computation. Each node contains several of these objects.
Author:
Sumeet Kulkarni
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    FIFOChannel(int sourceProduceAmt, int destAcceptAmt)
    Constructor that sets the source production amount and the destination consumption amount.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the amount of tokens the destination node needs to execute its process.
    int
    Returns the amount of tokens the source node produces after each process execution.
    pop()
    Returns the token at the front of the channel.
    void
    push(T token)
    Adds a token to the end of the channel.
    void
    setDestAcceptAmt(int destAcceptAmt)
    Sets the amount of tokens the destination node needs to execute its process.
    void
    setSourceProduceAmt(int sourceProduceAmt)
    Sets the amount of tokens the source node produces after each process execution.
    int
    Returns the size of the channel.
    Returns a string representation of the channel object.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FIFOChannel

      public FIFOChannel(int sourceProduceAmt, int destAcceptAmt)
      Constructor that sets the source production amount and the destination consumption amount.
      Parameters:
      sourceProduceAmt - the amount of tokens that the source node produces after executing a process
      destAcceptAmt - the amount of tokens the destination node requires from this channel to complete its computation
    • FIFOChannel

      public FIFOChannel()
      Default constructor. Sets source production amount and destination consumption amount to 0.
      See Also:
  • Method Details

    • pop

      public T pop()
      Returns the token at the front of the channel.
      Returns:
      the token at the front of the channel
    • push

      public void push(T token)
      Adds a token to the end of the channel.
      Parameters:
      token - the token to be added
    • size

      public int size()
      Returns the size of the channel.
      Returns:
      the size of the channel
    • getSourceProduceAmt

      public int getSourceProduceAmt()
      Returns the amount of tokens the source node produces after each process execution.
      Returns:
      the amount of tokens the source node produces after each process execution
    • setSourceProduceAmt

      public void setSourceProduceAmt(int sourceProduceAmt)
      Sets the amount of tokens the source node produces after each process execution.
      Parameters:
      sourceProduceAmt - the amount of tokens the source node produces after each process execution
    • getDestAcceptAmt

      public int getDestAcceptAmt()
      Returns the amount of tokens the destination node needs to execute its process.
      Returns:
      the amount of tokens the destination node needs to execute its process
    • setDestAcceptAmt

      public void setDestAcceptAmt(int destAcceptAmt)
      Sets the amount of tokens the destination node needs to execute its process.
      Parameters:
      destAcceptAmt - the amount of tokens the destination node needs to execute its process
    • toString

      public String toString()
      Returns a string representation of the channel object. Namely, it prints each token in the queue, assuming it has a defined toString() function itself.
      Overrides:
      toString in class Object