From 900a487d8a30a6398d9782908a7dc0625a87d2f0 Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Tue, 3 Mar 2020 14:52:11 +0100 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Aufruf von isCanceled an verschiedenen Stellen ergaenzt, so dass jetzt alle Prozesse angehalten werden sollten --- .../typeinference/unify/TypeUnifyTask.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 2d6dc8fa..d3ebe2c6 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -186,6 +186,12 @@ public class TypeUnifyTask extends RecursiveTask>> { usedTasks.cancel(); writeLog(nOfUnify.toString() + "cancel"); System.out.println("cancel"); + try { + logFile.write("Abbruch"); + } + catch (IOException e) { + System.err.println("log-File nicht vorhanden"); + } } */ rules = new RuleSet(logFile); @@ -303,6 +309,11 @@ public class TypeUnifyTask extends RecursiveTask>> { /* * Step 1: Repeated application of reduce, adapt, erase, swap */ + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } rekTiefe++; nOfUnify++; @@ -463,7 +474,11 @@ public class TypeUnifyTask extends RecursiveTask>> { // .collect(Collectors.toCollection(HashSet::new)); //Muss auskommentiert werden, wenn computeCartesianRecursive ENDE - + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } Set> eqPrimePrimeSet = new HashSet<>(); @@ -907,6 +922,11 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("wait "+ forkOrig.thNo); noOfThread--; res = forkOrig.join(); + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } //noOfThread++; forkOrig.writeLog("final Orig 1"); forkOrig.closeLogFile(); @@ -922,6 +942,11 @@ public class TypeUnifyTask extends RecursiveTask>> { synchronized (this) { noOfThread--; Set> fork_res = fork.join(); + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } //noOfThread++; writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben @@ -1013,6 +1038,11 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("wait "+ forkOrig.thNo); noOfThread--; res = forkOrig.join(); + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } //noOfThread++; forkOrig.writeLog("final Orig -1"); forkOrig.closeLogFile(); @@ -1028,6 +1058,11 @@ public class TypeUnifyTask extends RecursiveTask>> { synchronized (this) { noOfThread--; Set> fork_res = fork.join(); + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } //noOfThread++; writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben @@ -1089,6 +1124,11 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("wait "+ forkOrig.thNo); noOfThread--; res = forkOrig.join(); + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } //noOfThread++; forkOrig.writeLog("final Orig 2"); forkOrig.closeLogFile(); @@ -1103,6 +1143,11 @@ public class TypeUnifyTask extends RecursiveTask>> { synchronized (this) { noOfThread--; Set> fork_res = fork.join(); + synchronized (usedTasks) { + if (this.myIsCancelled()) { + return new HashSet<>(); + } + } //noOfThread++; writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben