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