00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.group.spmd;
00032
00033 import java.util.HashMap;
00034 import java.util.Iterator;
00035 import java.util.LinkedList;
00036
00037
00041 public class ProActiveSPMDGroupManager implements java.io.Serializable {
00042
00046 private Object spmdGroup = null;
00047
00053 private HashMap currentBarriers = new HashMap(4);
00054
00060 private LinkedList barrierTags = new LinkedList();
00061
00066 public void setSPMDGroup(Object o) {
00067 this.spmdGroup = o;
00068 }
00069
00074 public Object getSPMDGroup() {
00075 return this.spmdGroup;
00076 }
00077
00082 public void addToBarrierTags(String barrierID) {
00083 if (!this.barrierTags.contains(barrierID)) {
00084 this.barrierTags.add(barrierID);
00085 }
00086 }
00087
00093 public BarrierState getBarrierStateFor(String barrierName) {
00094 return (BarrierState) this.currentBarriers.get(barrierName);
00095 }
00096
00102 public void setAwaitedBarrierCalls(String barrierName, int nbCalls) {
00103 BarrierState bs = (BarrierState) this.currentBarriers.get(barrierName);
00104 if (bs == null) {
00105
00106
00107 bs = new BarrierState();
00108 this.addToCurrentBarriers(barrierName, bs);
00109 }
00110 bs.setAwaitedCalls(nbCalls);
00111 }
00112
00118 public void addToCurrentBarriers(String barrierName, BarrierState bs) {
00119 this.currentBarriers.put(barrierName, bs);
00120 }
00121
00127 public void remove(String barrierName) {
00128
00129 this.barrierTags.remove(barrierName);
00130
00131 this.currentBarriers.remove(barrierName);
00132 }
00133
00138 public boolean isTagsListEmpty() {
00139 return (this.barrierTags.size() == 0);
00140 }
00141
00146 public LinkedList getBarrierTags() {
00147 return this.barrierTags;
00148 }
00149
00156 public boolean checkExecution(LinkedList barrierTags) {
00157 if (barrierTags == null) {
00158 return true;
00159 }
00160 Iterator it = barrierTags.iterator();
00161 while (it.hasNext()) {
00162 if (this.currentBarriers.get((String) it.next()) != null) {
00163 return false;
00164 }
00165 }
00166 return true;
00167 }
00168
00173 public boolean isCurrentBarriersEmpty() {
00174 return (this.currentBarriers.size() == 0);
00175 }
00176 }