Skip to content

Commit 867167e

Browse files
committed
[PEx] Minor correction
Fix issue relating to intra-task stateful backtracking with dynamic machine creation
1 parent c02f0ed commit 867167e

File tree

1 file changed

+7
-14
lines changed
  • Src/PRuntimes/PExplicitRuntime/src/main/java/pexplicit/runtime/scheduler/explicit

1 file changed

+7
-14
lines changed

Src/PRuntimes/PExplicitRuntime/src/main/java/pexplicit/runtime/scheduler/explicit/StepState.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
* Represents the schedule state at a particular step
1313
*/
1414
public class StepState implements Serializable {
15-
/**
16-
* Mapping from machine type to list of machine instances
17-
*/
18-
private Map<Class<? extends PMachine>, List<PMachine>> machineListByType = new HashMap<>();
19-
2015
/**
2116
* Set of machines
2217
*/
@@ -31,7 +26,6 @@ public class StepState implements Serializable {
3126
public StepState copyState() {
3227
StepState stepState = new StepState();
3328

34-
stepState.machineListByType = new HashMap<>(this.machineListByType);
3529
stepState.machineSet = new TreeSet<>(this.machineSet);
3630

3731
stepState.machineLocalStates = new HashMap<>();
@@ -44,7 +38,6 @@ public StepState copyState() {
4438
}
4539

4640
public void clear() {
47-
machineListByType.clear();
4841
machineSet.clear();
4942
machineLocalStates.clear();
5043
}
@@ -54,12 +47,10 @@ public void resetToZero() {
5447
for (PMachine machine : PExplicitGlobal.getMachineSet()) {
5548
machine.reset();
5649
}
57-
machineListByType.clear();
5850
machineSet.clear();
5951
}
6052

6153
public void setTo(StepState input) {
62-
machineListByType = new HashMap<>(input.machineListByType);
6354
machineSet = new TreeSet<>(input.machineSet);
6455
machineLocalStates = new HashMap<>(input.machineLocalStates);
6556
assert (machineSet.size() == machineLocalStates.size());
@@ -80,10 +71,6 @@ public void setTo(StepState input) {
8071
* @param machine Machine to add
8172
*/
8273
public void makeMachine(PMachine machine) {
83-
if (!machineListByType.containsKey(machine.getClass())) {
84-
machineListByType.put(machine.getClass(), new ArrayList<>());
85-
}
86-
machineListByType.get(machine.getClass()).add(machine);
8774
machineSet.add(machine);
8875
}
8976

@@ -94,7 +81,13 @@ public void makeMachine(PMachine machine) {
9481
* @return Number of machine of a given type
9582
*/
9683
public int getMachineCount(Class<? extends PMachine> type) {
97-
return machineListByType.getOrDefault(type, new ArrayList<>()).size();
84+
int result = 0;
85+
for (PMachine m: machineSet) {
86+
if (type.isInstance(m)) {
87+
result++;
88+
}
89+
}
90+
return result;
9891
}
9992

10093
@Override

0 commit comments

Comments
 (0)