removed threadcounter from TypeUnifyTask

This commit is contained in:
NoName11234 2024-03-07 19:18:54 +01:00
parent d71e67cfdd
commit e91a9370df

View File

@ -72,11 +72,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
* Fuer die Threads
*/
protected UnifyResultModelParallel urm;
protected static int noOfThread = 0;
private static int totalnoOfThread = 0;
int thNo;
protected boolean one = false;
Integer MaxNoOfThreads = 128;
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
protected WriterActiveObject logFile;
@ -170,8 +168,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
this.logFile = logFile;
this.log = log;
this.pool = pool;
noOfThread++;
totalnoOfThread++;
//writeLog("thNo1 " + thNo);
thNo = totalnoOfThread;
@ -252,7 +249,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
.filter(x -> x.size()>1)
.collect(Collectors.toCollection(ArrayList::new));
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
noOfThread--;
if(parallel){
logFile.close();
@ -889,7 +885,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
/* Wenn parallel gearbeitet wird, wird je nach Varianz ein neuer Thread
* gestartet, der parallel weiterarbeitet.
*/
if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) {
if(parallel && (variance == 1)) {
Set<TypeUnify2Task> forks = new HashSet<>();
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
@ -939,7 +935,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
/* FORK ANFANG */
writeLog("wait "+ forkOrig.thNo);
noOfThread--;
res = forkOrig.join();
//noOfThread++;
@ -953,7 +948,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnify2Task fork : forks) {
noOfThread--;
Set<Set<UnifyPair>> fork_res = fork.join();
//noOfThread++;
@ -970,7 +964,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
//noOfThread++;
} else {
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
if(parallel && (variance == -1)) {
Set<TypeUnify2Task> forks = new HashSet<>();
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
@ -1018,7 +1012,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
/* FORK ANFANG */
writeLog("wait "+ forkOrig.thNo);
noOfThread--;
res = forkOrig.join();
//noOfThread++;
@ -1032,7 +1025,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnify2Task fork : forks) {
noOfThread--;
Set<Set<UnifyPair>> fork_res = fork.join();
//noOfThread++;
@ -1050,7 +1042,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//noOfThread++;
} else {
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
if(parallel && (variance == 2)) {
writeLog("var2einstieg");
Set<TypeUnify2Task> forks = new HashSet<>();
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
@ -1083,7 +1075,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
/* FORK ANFANG */
writeLog("wait "+ forkOrig.thNo);
noOfThread--;
res = forkOrig.join();
//noOfThread++;
@ -1097,7 +1088,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
/* FORK ENDE */
forks.forEach(x -> writeLog("wait: " + x.thNo));
for(TypeUnify2Task fork : forks) {
noOfThread--;
Set<Set<UnifyPair>> fork_res = fork.join();
//noOfThread++;
@ -2513,13 +2503,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
if (log && finalresult) {
if(parallel){
logFile.write("Thread no.:" + thNo + "\n"
+ "noOfThread:" + noOfThread + "\n"
+ "parallel:" + parallel + "\n"
+ str+"\n\n"
);
}else{
logFile.writeNonThreaded("Thread no.:" + thNo + "\n"
+ "noOfThread:" + noOfThread + "\n"
+ "parallel:" + parallel + "\n"
+ str+"\n\n"
);