removed useless synchronized-blocks and concenated multiple writes to logfile

This commit is contained in:
NoName11234 2024-01-23 17:57:07 +01:00
parent 0807885465
commit 441e50a70d

View File

@ -378,8 +378,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
eq0.forEach(x -> x.disableCondWildcards()); eq0.forEach(x -> x.disableCondWildcards());
writeLog(nOfUnify.toString() + " Unifikation nach applyTypeUnificationRules: " + eq.toString()); writeLog(nOfUnify.toString() + " Unifikation nach applyTypeUnificationRules: " + eq.toString() + "\n"
writeLog(nOfUnify.toString() + " Oderconstraints nach applyTypeUnificationRules: " + oderConstraints.toString()); + nOfUnify.toString() + " Oderconstraints nach applyTypeUnificationRules: " + oderConstraints.toString());
/* /*
* Step 2 and 3: Create a subset eq1s of pairs where both sides are TPH and eq2s of the other pairs * Step 2 and 3: Create a subset eq1s of pairs where both sides are TPH and eq2s of the other pairs
@ -438,8 +438,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
if(!undefinedPairs.isEmpty()) { if(!undefinedPairs.isEmpty()) {
noUndefPair++; noUndefPair++;
for (UnifyPair up : undefinedPairs) { for (UnifyPair up : undefinedPairs) {
writeLog(noUndefPair.toString() + " UndefinedPairs; " + up); writeLog(noUndefPair.toString() + " UndefinedPairs; " + up + "\n"
writeLog("BasePair; " + up.getBasePair()); + "BasePair; " + up.getBasePair());
} }
Set<Set<UnifyPair>> error = new HashSet<>(); Set<Set<UnifyPair>> error = new HashSet<>();
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new)); undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
@ -806,8 +806,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
*/ */
List<Set<UnifyPair>> nextSetasListOderConstraints = new ArrayList<>(); List<Set<UnifyPair>> nextSetasListOderConstraints = new ArrayList<>();
writeLog("nextSet: " + nextSet.toString()); writeLog("nextSet: " + nextSet.toString() + "\n"
writeLog("nextSetasList: " + nextSetasList.toString()); + "nextSetasList: " + nextSetasList.toString());
/* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang /* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang
if (variance == 1) { if (variance == 1) {
@ -935,15 +935,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
/* FORK ENDE */ /* FORK ENDE */
synchronized (this) { writeLog("a in " + variance + " "+ a + "\n" +
writeLog("a in " + variance + " "+ a); "nextSetasListRest: " + nextSetasListRest.toString());
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
}
while (!nextSetasList.isEmpty()) { while (!nextSetasList.isEmpty()) {
Set<UnifyPair> nSaL = nextSetasList.remove(0); Set<UnifyPair> nSaL = nextSetasList.remove(0);
synchronized (this) { //nextSetasList.remove(nSaL); //nextSetasList.remove(nSaL);
writeLog("1 RM" + nSaL.toString()); writeLog("1 RM" + nSaL.toString());
}
if (!oderConstraint) { if (!oderConstraint) {
@ -975,7 +974,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe); //res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
/* FORK ANFANG */ /* FORK ANFANG */
synchronized (this) {
writeLog("wait "+ forkOrig.thNo); writeLog("wait "+ forkOrig.thNo);
noOfThread--; noOfThread--;
res = forkOrig.join(); res = forkOrig.join();
@ -991,12 +990,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
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
//add_res.add(fork_res); //add_res.add(fork_res);
};
/* FORK ENDE */ /* FORK ENDE */
forks.forEach(x -> writeLog("wait: " + x.thNo)); forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnify2Task fork : forks) { for(TypeUnify2Task fork : forks) {
synchronized (this) {
noOfThread--; noOfThread--;
Set<Set<UnifyPair>> fork_res = fork.join(); Set<Set<UnifyPair>> fork_res = fork.join();
synchronized (usedTasks) { synchronized (usedTasks) {
@ -1005,17 +1002,16 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
} }
//noOfThread++; //noOfThread++;
writeLog("Join " + new Integer(fork.thNo).toString());
//noOfThread--; an das Ende von compute verschoben //noOfThread--; an das Ende von compute verschoben
writeLog("fork_res: " + fork_res.toString()); writeLog("Join " + new Integer(fork.thNo).toString() + "\n" +
writeLog(new Boolean((isUndefinedPairSetSet(fork_res))).toString()); "fork_res: " + fork_res.toString() + "\n" +
new Boolean((isUndefinedPairSetSet(fork_res))).toString());
add_res.add(fork_res); add_res.add(fork_res);
if (!isUndefinedPairSetSet(fork_res)) { if (!isUndefinedPairSetSet(fork_res)) {
aParDef.add(fork.getNextSetElement()); aParDef.add(fork.getNextSetElement());
} }
fork.writeLog("final 1"); fork.writeLog("final 1");
fork.closeLogFile(); fork.closeLogFile();
};
} }
//noOfThread++; //noOfThread++;
} else { } else {
@ -1037,15 +1033,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
/* FORK ENDE */ /* FORK ENDE */
synchronized (this) {
writeLog("a in " + variance + " "+ a); writeLog("a in " + variance + " "+ a + "\n" +
writeLog("nextSetasListRest: " + nextSetasListRest.toString()); "nextSetasListRest: " + nextSetasListRest.toString());
}
while (!nextSetasList.isEmpty()) { while (!nextSetasList.isEmpty()) {
Set<UnifyPair> nSaL = nextSetasList.remove(0); Set<UnifyPair> nSaL = nextSetasList.remove(0);
synchronized (this) { //nextSetasList.remove(nSaL); //nextSetasList.remove(nSaL);
writeLog("-1 RM" + nSaL.toString()); writeLog("-1 RM" + nSaL.toString());
}
if (!oderConstraint) { if (!oderConstraint) {
/* statistics sameEq wird nicht betrachtet ANGFANG /* statistics sameEq wird nicht betrachtet ANGFANG
@ -1076,7 +1071,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe); //res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
/* FORK ANFANG */ /* FORK ANFANG */
synchronized (this) {
writeLog("wait "+ forkOrig.thNo); writeLog("wait "+ forkOrig.thNo);
noOfThread--; noOfThread--;
res = forkOrig.join(); res = forkOrig.join();
@ -1092,12 +1086,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
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
//add_res.add(fork_res); //add_res.add(fork_res);
};
/* FORK ENDE */ /* FORK ENDE */
forks.forEach(x -> writeLog("wait: " + x.thNo)); forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnify2Task fork : forks) { for(TypeUnify2Task fork : forks) {
synchronized (this) {
noOfThread--; noOfThread--;
Set<Set<UnifyPair>> fork_res = fork.join(); Set<Set<UnifyPair>> fork_res = fork.join();
synchronized (usedTasks) { synchronized (usedTasks) {
@ -1117,7 +1109,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
fork.writeLog("final -1"); fork.writeLog("final -1");
fork.closeLogFile(); fork.closeLogFile();
}; };
}
//noOfThread++; //noOfThread++;
} else { } else {
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) { if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
@ -1139,10 +1131,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
/* FORK ENDE */ /* FORK ENDE */
synchronized (this) { writeLog("a in " + variance + " "+ a + "\n" +
writeLog("a in " + variance + " "+ a); "nextSetasListRest: " + nextSetasListRest.toString());
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
}
while (!nextSetasList.isEmpty()) { while (!nextSetasList.isEmpty()) {
Set<UnifyPair> nSaL = nextSetasList.remove(0); Set<UnifyPair> nSaL = nextSetasList.remove(0);
//nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03 //nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03
@ -1162,7 +1153,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe); //res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
/* FORK ANFANG */ /* FORK ANFANG */
synchronized (this) {
writeLog("wait "+ forkOrig.thNo); writeLog("wait "+ forkOrig.thNo);
noOfThread--; noOfThread--;
res = forkOrig.join(); res = forkOrig.join();
@ -1178,11 +1169,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
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
//add_res.add(fork_res); //vermutlich falsch //add_res.add(fork_res); //vermutlich falsch
};
/* FORK ENDE */ /* FORK ENDE */
forks.forEach(x -> writeLog("wait: " + x.thNo)); forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnify2Task fork : forks) { for(TypeUnify2Task fork : forks) {
synchronized (this) {
noOfThread--; noOfThread--;
Set<Set<UnifyPair>> fork_res = fork.join(); Set<Set<UnifyPair>> fork_res = fork.join();
synchronized (usedTasks) { synchronized (usedTasks) {
@ -1196,7 +1186,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
add_res.add(fork_res); add_res.add(fork_res);
fork.writeLog("final 2"); fork.writeLog("final 2");
fork.closeLogFile(); fork.closeLogFile();
};
} }
//noOfThread++; //noOfThread++;
} else {//parallel = false oder MaxNoOfThreads ist erreicht, sequentiell weiterarbeiten } else {//parallel = false oder MaxNoOfThreads ist erreicht, sequentiell weiterarbeiten
@ -1525,15 +1514,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//NOCH NICHT korrekt PL 2018-10-12 //NOCH NICHT korrekt PL 2018-10-12
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) //nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
// .collect(Collectors.toCollection(ArrayList::new)); // .collect(Collectors.toCollection(ArrayList::new));
writeLog("res (undef): " + res.toString()); writeLog("res (undef): " + res.toString() + "\n" +
writeLog("abhSubst: " + abhSubst.toString()); "abhSubst: " + abhSubst.toString() + "\n" +
writeLog("a2: " + rekTiefe + " " + a.toString()); "a2: " + rekTiefe + " " + a.toString() + "\n" +
writeLog("Durchschnitt: " + durchschnitt.toString()); "Durchschnitt: " + durchschnitt.toString() + "\n" +
writeLog("nextSet: " + nextSet.toString()); "nextSet: " + nextSet.toString() + "\n" +
writeLog("nextSetasList: " + nextSetasList.toString()); "nextSetasList: " + nextSetasList.toString() + "\n" +
writeLog("Number first erased Elements (undef): " + (len - nofstred)); "Number first erased Elements (undef): " + (len - nofstred) + "\n" +
writeLog("Number second erased Elements (undef): " + (nofstred- nextSetasList.size())); "Number second erased Elements (undef): " + (nofstred- nextSetasList.size()) + "\n" +
writeLog("Number erased Elements (undef): " + (len - nextSetasList.size())); "Number erased Elements (undef): " + (len - nextSetasList.size()));
noAllErasedElements = noAllErasedElements + (len - nextSetasList.size()); noAllErasedElements = noAllErasedElements + (len - nextSetasList.size());
writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString()); writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString());
noBacktracking++; noBacktracking++;
@ -1993,10 +1982,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
} }
writeLog("eq2s: " + eq2s.toString()); writeLog("eq2s: " + eq2s.toString() + "\n" +
writeLog("eq2sAsListFst: " + eq2sAsListFst.toString()); "eq2sAsListFst: " + eq2sAsListFst.toString() + "\n" +
writeLog("eq2sAsListSnd: " + eq2sAsListSnd.toString()); "eq2sAsListSnd: " + eq2sAsListSnd.toString() + "\n" +
writeLog("eq2sAsListBack: " + eq2sAsListBack.toString()); "eq2sAsListBack: " + eq2sAsListBack.toString());
eq2sAsList.addAll(eq2sAsListFst); eq2sAsList.addAll(eq2sAsListFst);
eq2sAsList.addAll(eq2sAsListSnd); eq2sAsList.addAll(eq2sAsListSnd);