Package org.jcsp.net2
Class BarrierManager
java.lang.Object
org.jcsp.net2.BarrierManager
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final Hashtable
The table containing the Barriers.private static int
The index for the next Barrier to be created.private static BarrierManager
Singleton instance of the BarrierManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
create
(int idx, BarrierData bd) Stores a barrier with the given index in the table.(package private) void
create
(BarrierData bd) Allocates a new number to the Barrier, and stores it in the table.(package private) BarrierData
getBarrier
(int idx) Retrieves a barrier from the table(package private) static BarrierManager
Allows getting of the singleton instance.(package private) void
removeBarrier
(BarrierData data) Removes the given barrier from the table of barriers.
-
Field Details
-
index
private static int indexThe 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
The table containing the Barriers. An Integer (object wrapped int) is used as the key, and the BarrierData as the value. -
instance
Singleton instance of the BarrierManager
-
-
Constructor Details
-
BarrierManager
private BarrierManager()Private default constructor. Used for the singleton instance.
-
-
Method Details
-
getInstance
Allows getting of the singleton instance.- Returns:
- The singleton instance of the BarrierManager
-
create
Allocates a new number to the Barrier, and stores it in the table.- Parameters:
bd
- The BarrierData for the Barrier
-
create
Stores a barrier with the given index in the table.- Parameters:
idx
- The index to use for the barrierbd
- The BarrierData representing the barrier- Throws:
IllegalArgumentException
- If a barrier of the given index already exists.
-
getBarrier
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
Removes the given barrier from the table of barriers.- Parameters:
data
- The BarrierData object of the barrier to be removed
-