Package org.jcsp.net2
Class BarrierManager
- java.lang.Object
-
- org.jcsp.net2.BarrierManager
-
final class BarrierManager extends java.lang.ObjectManages 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:
NetBarrier
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashtablebarriersThe table containing the Barriers.private static intindexThe index for the next Barrier to be created.private static BarrierManagerinstanceSingleton instance of the BarrierManager
-
Constructor Summary
Constructors Modifier Constructor Description privateBarrierManager()Private default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcreate(int idx, BarrierData bd)Stores a barrier with the given index in the table.(package private) voidcreate(BarrierData bd)Allocates a new number to the Barrier, and stores it in the table.(package private) BarrierDatagetBarrier(int idx)Retrieves a barrier from the table(package private) static BarrierManagergetInstance()Allows getting of the singleton instance.(package private) voidremoveBarrier(BarrierData data)Removes the given barrier from the table of barriers.
-
-
-
Field Detail
-
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 java.util.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
-
-
Method Detail
-
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 java.lang.IllegalArgumentExceptionStores a barrier with the given index in the table.- Parameters:
idx- The index to use for the barrierbd- The BarrierData representing the barrier- Throws:
java.lang.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
-
-