forked from JavaTX/JavaCompilerCore
removed ThreadCounter from TypeUnifyTask
This commit is contained in:
parent
e4af54a2bf
commit
8fb7d3e7b5
@ -13,6 +13,7 @@ import java.util.List;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.RecursiveTask;
|
import java.util.concurrent.RecursiveTask;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
@ -79,11 +80,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* Fuer die Threads
|
* Fuer die Threads
|
||||||
*/
|
*/
|
||||||
UnifyResultModel urm;
|
UnifyResultModel urm;
|
||||||
protected static int noOfThread = 0;
|
|
||||||
private static int totalnoOfThread = 0;
|
private static int totalnoOfThread = 0;
|
||||||
int thNo;
|
int thNo;
|
||||||
protected boolean one = false;
|
protected boolean one = false;
|
||||||
Integer MaxNoOfThreads = 128;
|
|
||||||
|
|
||||||
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||||
Writer logFile;
|
Writer logFile;
|
||||||
@ -184,8 +183,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
this.parallel = parallel;
|
this.parallel = parallel;
|
||||||
this.logFile = logFile;
|
this.logFile = logFile;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
|
||||||
noOfThread++;
|
|
||||||
totalnoOfThread++;
|
totalnoOfThread++;
|
||||||
//writeLog("thNo1 " + thNo);
|
//writeLog("thNo1 " + thNo);
|
||||||
thNo = totalnoOfThread;
|
thNo = totalnoOfThread;
|
||||||
@ -274,7 +272,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
.filter(x -> x.size()>1)
|
.filter(x -> x.size()>1)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
||||||
noOfThread--;
|
|
||||||
try {
|
try {
|
||||||
logFile.close();
|
logFile.close();
|
||||||
}
|
}
|
||||||
@ -929,7 +926,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/* Wenn parallel gearbeitet wird, wird je nach Varianz ein neuer Thread
|
/* Wenn parallel gearbeitet wird, wird je nach Varianz ein neuer Thread
|
||||||
* gestartet, der parallel weiterarbeitet.
|
* gestartet, der parallel weiterarbeitet.
|
||||||
*/
|
*/
|
||||||
if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == 1)) {
|
||||||
Set<TypeUnify2Task> 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);
|
||||||
@ -989,7 +986,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
writeLog("wait "+ forkOrig.thNo);
|
writeLog("wait "+ forkOrig.thNo);
|
||||||
noOfThread--;
|
|
||||||
res = forkOrig.join();
|
res = forkOrig.join();
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1009,7 +1005,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||||
for(TypeUnify2Task fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
noOfThread--;
|
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1031,7 +1026,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
//noOfThread++;
|
//noOfThread++;
|
||||||
} else {
|
} else {
|
||||||
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == -1)) {
|
||||||
Set<TypeUnify2Task> 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);
|
||||||
@ -1090,7 +1085,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
writeLog("wait "+ forkOrig.thNo);
|
writeLog("wait "+ forkOrig.thNo);
|
||||||
noOfThread--;
|
|
||||||
res = forkOrig.join();
|
res = forkOrig.join();
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1110,7 +1104,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||||
for(TypeUnify2Task fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
noOfThread--;
|
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1132,7 +1125,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
//noOfThread++;
|
//noOfThread++;
|
||||||
} else {
|
} else {
|
||||||
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == 2)) {
|
||||||
writeLog("var2einstieg");
|
writeLog("var2einstieg");
|
||||||
Set<TypeUnify2Task> forks = new HashSet<>();
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||||
@ -1176,7 +1169,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
writeLog("wait "+ forkOrig.thNo);
|
writeLog("wait "+ forkOrig.thNo);
|
||||||
noOfThread--;
|
|
||||||
res = forkOrig.join();
|
res = forkOrig.join();
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1195,7 +1187,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||||
for(TypeUnify2Task fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
noOfThread--;
|
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -2617,7 +2608,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (log && finalresult) {
|
if (log && finalresult) {
|
||||||
try {
|
try {
|
||||||
logFile.write("Thread no.:" + thNo + "\n");
|
logFile.write("Thread no.:" + thNo + "\n");
|
||||||
logFile.write("noOfThread:" + noOfThread + "\n");
|
|
||||||
logFile.write("parallel:" + parallel + "\n");
|
logFile.write("parallel:" + parallel + "\n");
|
||||||
logFile.write(str+"\n\n");
|
logFile.write(str+"\n\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user