modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java

modified:   ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
close log-Files
TypeUnifyTask in TypeUnify2Task bei Abarbeitung oderconstraints umgetauscht
This commit is contained in:
Martin Plümicke 2019-02-20 09:40:06 +01:00
parent 362e797b10
commit 72705ac868
2 changed files with 27 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.typeinference.unify; package de.dhbwstuttgart.typeinference.unify;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -37,6 +38,17 @@ public class TypeUnify2Task extends TypeUnifyTask {
else else
*/ */
noOfThread--; noOfThread--;
return res; return res;
}
public void closeLogFile() {
try {
logFile.close();
}
catch (IOException ioE) {
System.err.println("no log-File" + thNo);
}
} }
} }

View File

@ -218,6 +218,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField); Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField);
noOfThread--; noOfThread--;
try {
logFile.close();
}
catch (IOException ioE) {
System.err.println("no log-File");
}
if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } if (isUndefinedPairSetSet(res)) { return new HashSet<>(); }
else return res; else return res;
} }
@ -960,6 +966,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("wait "+ forkOrig.thNo); writeLog("wait "+ forkOrig.thNo);
res = forkOrig.join(); res = forkOrig.join();
forkOrig.writeLog("final Orig 1"); forkOrig.writeLog("final Orig 1");
forkOrig.closeLogFile();
//Set<Set<UnifyPair>> fork_res = forkOrig.join(); //Set<Set<UnifyPair>> fork_res = forkOrig.join();
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString()); writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
//noOfThread--; an das Ende von compute verschoben //noOfThread--; an das Ende von compute verschoben
@ -980,6 +987,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
aParDef.add(fork.getNextSetElement()); aParDef.add(fork.getNextSetElement());
} }
fork.writeLog("final 1"); fork.writeLog("final 1");
fork.closeLogFile();
}; };
} }
noOfThread++; noOfThread++;
@ -1022,6 +1030,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("wait "+ forkOrig.thNo); writeLog("wait "+ forkOrig.thNo);
res = forkOrig.join(); res = forkOrig.join();
forkOrig.writeLog("final Orig -1"); forkOrig.writeLog("final Orig -1");
forkOrig.closeLogFile();
//Set<Set<UnifyPair>> fork_res = forkOrig.join(); //Set<Set<UnifyPair>> fork_res = forkOrig.join();
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString()); writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
//noOfThread--; an das Ende von compute verschoben //noOfThread--; an das Ende von compute verschoben
@ -1042,13 +1051,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
aParDef.add(fork.getNextSetElement()); aParDef.add(fork.getNextSetElement());
} }
fork.writeLog("final -1"); fork.writeLog("final -1");
fork.closeLogFile();
}; };
} }
noOfThread++; noOfThread++;
} else { } else {
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) { if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
writeLog("var2einstieg"); writeLog("var2einstieg");
Set<TypeUnifyTask> forks = new HashSet<>(); Set<TypeUnify2Task> forks = new HashSet<>();
Set<UnifyPair> newEqOrig = new HashSet<>(eq); Set<UnifyPair> newEqOrig = new HashSet<>(eq);
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems); Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
List<Set<Set<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints); List<Set<Set<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
@ -1083,6 +1093,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("wait "+ forkOrig.thNo); writeLog("wait "+ forkOrig.thNo);
res = forkOrig.join(); res = forkOrig.join();
forkOrig.writeLog("final Orig 2"); forkOrig.writeLog("final Orig 2");
forkOrig.closeLogFile();
//Set<Set<UnifyPair>> fork_res = forkOrig.join(); //Set<Set<UnifyPair>> fork_res = forkOrig.join();
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString()); writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
//noOfThread--; an das Ende von compute verschoben //noOfThread--; an das Ende von compute verschoben
@ -1090,13 +1101,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}; };
/* FORK ENDE */ /* FORK ENDE */
forks.forEach(x -> writeLog("wait: " + x.thNo)); forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnifyTask fork : forks) { for(TypeUnify2Task fork : forks) {
synchronized (this) { synchronized (this) {
Set<Set<UnifyPair>> fork_res = fork.join(); Set<Set<UnifyPair>> fork_res = fork.join();
writeLog("Join " + new Integer(fork.thNo).toString()); writeLog("Join " + new Integer(fork.thNo).toString());
//noOfThread--; an das Ende von compute verschoben //noOfThread--; an das Ende von compute verschoben
add_res.add(fork_res); add_res.add(fork_res);
fork.writeLog("final 2"); fork.writeLog("final 2");
fork.closeLogFile();
}; };
} }
noOfThread++; noOfThread++;