Package org.jcsp.net2

Class BarrierManager

java.lang.Object
org.jcsp.net2.BarrierManager

final class BarrierManager extends Object
Manages the networked Barriers in the system. This object wraps a Hashtable containing the NetBarrier data objects, and manages the allocation and removal of NetBarrier front ends within the JCSP networking architecture. For information on the NetBarrier, see the appropriate documentation.
See Also:
  • Field Details

    • index

      private static int index
      The index for the next Barrier to be created. We start at 50 as it allows us to have up to 50 default Barriers with set numbers.
    • barriers

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

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

    • BarrierManager

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

    • getInstance

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

      void create(BarrierData bd)
      Allocates a new number to the Barrier, and stores it in the table.
      Parameters:
      bd - The BarrierData for the Barrier
    • create

      void create(int idx, BarrierData bd) throws IllegalArgumentException
      Stores a barrier with the given index in the table.
      Parameters:
      idx - The index to use for the barrier
      bd - The BarrierData representing the barrier
      Throws:
      IllegalArgumentException - If a barrier of the given index already exists.
    • getBarrier

      BarrierData getBarrier(int idx)
      Retrieves a barrier from the table
      Parameters:
      idx - Index in the table to retrieve the barrier from.
      Returns:
      The BarrierData object for the barrier.
    • removeBarrier

      void removeBarrier(BarrierData data)
      Removes the given barrier from the table of barriers.
      Parameters:
      data - The BarrierData object of the barrier to be removed