From df0d02cdea8d57da55d2a1e3e741fa07861e56e7 Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Fri, 6 Mar 2020 13:57:01 +0100 Subject: [PATCH] Revert " modified: src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java" This reverts commit 47ec1dca5aa43dda026b1582cc9a9fc506e93a63. --- .../de/dhbwstuttgart/core/JavaTXCompiler.java | 16 ++--------- .../typeinference/unify/TypeUnify.java | 16 +++++------ .../typeinference/unify/TypeUnify2Task.java | 4 +-- .../typeinference/unify/TypeUnifyTask.java | 28 ++++++------------- .../typeinference/unify/UnifyTaskModel.java | 4 --- .../typeinference/unify/controlCancel.java | 5 ---- 6 files changed, 21 insertions(+), 52 deletions(-) delete mode 100644 src/main/java/de/dhbwstuttgart/typeinference/unify/controlCancel.java diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index 13f9d0af..d44ac77f 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -35,7 +35,6 @@ import de.dhbwstuttgart.typeinference.unify.UnifyResultListener; import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl; import de.dhbwstuttgart.typeinference.unify.UnifyResultModel; import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel; -import de.dhbwstuttgart.typeinference.unify.controlCancel; import java.io.File; import java.io.FileOutputStream; @@ -55,15 +54,6 @@ public class JavaTXCompiler { public final Map sourceFiles = new HashMap<>(); Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll? public volatile UnifyTaskModel usedTasks = new UnifyTaskModel(); - public controlCancel cC = () -> false; //kann z.B. durche eine Implementierung - //von dem Eclipse Interface IProgressMonitor - //instanziert werden. - - public JavaTXCompiler(File sourceFile, controlCancel cC) throws IOException, ClassNotFoundException { - this(Arrays.asList(sourceFile)); - this.cC = cC; - INSTANCE = this; - } public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException { this(Arrays.asList(sourceFile)); @@ -446,7 +436,7 @@ public class JavaTXCompiler { return ret; }).collect(Collectors.toCollection(ArrayList::new)); unify.unifyAsync(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm, - usedTasks, cC); + usedTasks); } catch (IOException e) { System.err.println("kein LogFile"); } @@ -617,7 +607,7 @@ public class JavaTXCompiler { UnifyResultListenerImpl li = new UnifyResultListenerImpl(); urm.addUnifyResultListener(li); unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm, - usedTasks, cC); + usedTasks); System.out.println("RESULT Final: " + li.getResults()); logFile.write("RES_FINAL: " + li.getResults().toString() + "\n"); logFile.flush(); @@ -629,7 +619,7 @@ public class JavaTXCompiler { // oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, // finiteClosure)); Set> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, - finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure), usedTasks, cC); + finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure), usedTasks); System.out.println("RESULT: " + result); logFile.write("RES: " + result.toString() + "\n"); logFile.flush(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java index 79c7dc2d..6b045547 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java @@ -28,8 +28,8 @@ public class TypeUnify { * @param cons * @return */ - public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks, cC); + public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks); ForkJoinPool pool = new ForkJoinPool(); pool.invoke(unifyTask); Set> res = unifyTask.join(); @@ -54,8 +54,8 @@ public class TypeUnify { * @param ret * @return */ - public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks, cC); + public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks); ForkJoinPool pool = new ForkJoinPool(); pool.invoke(unifyTask); return ret; @@ -72,8 +72,8 @@ public class TypeUnify { * @param ret * @return */ - public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks, cC); + public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks); ForkJoinPool pool = new ForkJoinPool(); pool.invoke(unifyTask); Set> res = unifyTask.join(); @@ -105,8 +105,8 @@ public class TypeUnify { * @param cons * @return */ - public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, usedTasks, cC); + public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) { + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, usedTasks); Set> res = unifyTask.compute(); try { logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n"); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index 5920dd84..54c3fb99 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -18,8 +18,8 @@ public class TypeUnify2Task extends TypeUnifyTask { Set> setToFlatten; - public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, controlCancel cC) { - super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) { + super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); this.setToFlatten = setToFlatten; this.nextSetElement = nextSetElement; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 22409031..8e940d70 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -122,16 +122,10 @@ public class TypeUnifyTask extends RecursiveTask>> { static Integer noShortendElements = 0; - /* Field wird nicht mehr benutzt - * Der cancel-Mechanismus wird durch die Implementierung von controlCancel - * erledigt. Boolean myIsCanceled = false; - */ volatile UnifyTaskModel usedTasks; - volatile controlCancel cC; - public TypeUnifyTask() { rules = new RuleSet(); } @@ -151,7 +145,7 @@ public class TypeUnifyTask extends RecursiveTask>> { */ - public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, controlCancel cC) { + public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) { synchronized (this) { this.eq = eq; //this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new)); @@ -171,7 +165,6 @@ public class TypeUnifyTask extends RecursiveTask>> { this.parallel = parallel; this.logFile = logFile; this.log = log; - this.cC = cC; noOfThread++; totalnoOfThread++; @@ -235,17 +228,12 @@ public class TypeUnifyTask extends RecursiveTask>> { } } */ - /* Methode wird nicht mehr benutzt - * Der cancel-Mechanismus wird durch die Implementierung von controlCancel - * erledigt. void myCancel(Boolean b) { myIsCanceled = true; } - */ public boolean myIsCancelled() { - //return myIsCanceled; - return cC.isCanceled(); + return myIsCanceled; } protected Set> compute() { @@ -851,7 +839,7 @@ public class TypeUnifyTask extends RecursiveTask>> { newElemsOrig.add(a); /* FORK ANFANG */ - TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); //forks.add(forkOrig); synchronized(usedTasks) { if (this.myIsCancelled()) { @@ -903,7 +891,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> newElems = new HashSet<>(elems); List>> newOderConstraints = new ArrayList<>(oderConstraints); newElems.add(nSaL); - TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); forks.add(fork); synchronized(usedTasks) { if (this.myIsCancelled()) { @@ -957,7 +945,7 @@ public class TypeUnifyTask extends RecursiveTask>> { newElemsOrig.add(a); /* FORK ANFANG */ - TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); //forks.add(forkOrig); synchronized(usedTasks) { if (this.myIsCancelled()) { @@ -1009,7 +997,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> newElems = new HashSet<>(elems); List>> newOderConstraints = new ArrayList<>(oderConstraints); newElems.add(nSaL); - TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); forks.add(fork); synchronized(usedTasks) { if (this.myIsCancelled()) { @@ -1064,7 +1052,7 @@ public class TypeUnifyTask extends RecursiveTask>> { newElemsOrig.add(a); /* FORK ANFANG */ - TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); //forks.add(forkOrig); synchronized(usedTasks) { if (this.myIsCancelled()) { @@ -1085,7 +1073,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> newElems = new HashSet<>(elems); List>> newOderConstraints = new ArrayList<>(oderConstraints); newElems.add(nSaL); - TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC); + TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks); forks.add(fork); synchronized(usedTasks) { if (this.myIsCancelled()) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyTaskModel.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyTaskModel.java index a385b974..e60054f0 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyTaskModel.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyTaskModel.java @@ -10,13 +10,9 @@ public class UnifyTaskModel { usedTasks.add(t); } - /* Methode wird nicht mehr benutzt - * Der cancel-Mechanismus wird durch die Implementierung von controlCancel - * erledigt. public synchronized void cancel() { for(TypeUnifyTask t : usedTasks) { t.myCancel(true); } } - */ } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/controlCancel.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/controlCancel.java deleted file mode 100644 index 1f9835c2..00000000 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/controlCancel.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.dhbwstuttgart.typeinference.unify; - -public interface controlCancel { - public Boolean isCanceled(); -}