Package org.jcsp.net2

Class ChannelManager

java.lang.Object
org.jcsp.net2.ChannelManager

final class ChannelManager extends Object
A class used to manage the networked channels on the Node. This is an internal object to JCSP networking. For a description of networked channels, see the relevant documentation.
See Also:
  • Field Details

    • index

      private static int index
      The index for the next channel to be created. We start at 50 as it allows us to have up to 50 default channels, for example for use to connect to a Channel Name Server.
    • channels

      private final Hashtable channels
      The table containing the channels. An Integer (object wrapped int) is used as the key, and the ChannelData as the value.
    • instance

      private static ChannelManager instance
      Singleton instance of the ChannelManager
  • Constructor Details

    • ChannelManager

      private ChannelManager()
      Private default constructor. Used for the singleton instance.
  • Method Details

    • getInstance

      static ChannelManager getInstance()
      Allows getting of the singleton instance.
      Returns:
      The singleton instance of the ChannelManager
    • create

      void create(ChannelData cd)
      Allocates a new number to the channel, and stores it in the table.
      Parameters:
      cd - The ChannelData for the channel
    • create

      void create(int idx, ChannelData cd) throws IllegalArgumentException
      Stores a channel in the given index in the table.
      Parameters:
      idx - The index to use for the channel
      cd - The ChannelData for the channel
      Throws:
      IllegalArgumentException - If a channel of the given index already exists.
    • getChannel

      ChannelData getChannel(int idx)
      Retrieves a channel from the table
      Parameters:
      idx - Index in the table to retrieve the channel from.
      Returns:
      The ChannelData object for the channel.
    • removeChannel

      void removeChannel(ChannelData data)
      Removes a channel from the table.
      Parameters:
      data - ChannelData for channel to remove