diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java index 1beba7c..f528838 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java @@ -26,9 +26,10 @@ public class TypeUnify { */ public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModelParallel ret, UnifyTaskModelParallel usedTasks) { ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); + ConstraintSetRepository constraintSetRepository = new ConstraintSetRepository(); usedTasks.setPool(pool); ret.setPool(pool); - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret); + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, constraintSetRepository); pool.invoke(unifyTask); Set> res = unifyTask.join(); try { @@ -52,11 +53,12 @@ public class TypeUnify { * @param ret * @return */ - public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModelParallel ret, UnifyTaskModelParallel usedTasks) { + public UnifyResultModelParallel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModelParallel ret, UnifyTaskModelParallel usedTasks) { ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); + ConstraintSetRepository constraintSetRepository = new ConstraintSetRepository(); usedTasks.setPool(pool); ret.setPool(pool); - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret); + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, constraintSetRepository); pool.invoke(unifyTask); return ret; } @@ -72,11 +74,12 @@ public class TypeUnify { * @param ret * @return */ - public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModelParallel ret, UnifyTaskModelParallel usedTasks) { + public UnifyResultModelParallel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModelParallel ret, UnifyTaskModelParallel usedTasks) { ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); + ConstraintSetRepository constraintSetRepository = new ConstraintSetRepository(); usedTasks.setPool(pool); ret.setPool(pool); - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, statistics); + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, constraintSetRepository, statistics); pool.invoke(unifyTask); Set> res = unifyTask.join(); try { @@ -110,7 +113,8 @@ public class TypeUnify { * @return */ public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModelParallel ret, UnifyTaskModelParallel usedTasks) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret); + ConstraintSetRepository constraintSetRepository = new ConstraintSetRepository(); + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, constraintSetRepository); unifyTask.statistics = statistics; Set> res = unifyTask.compute(); try { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index e74f6bb..d0a856a 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -15,59 +15,58 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; public class TypeUnify2Task extends TypeUnifyTask { - - Set> setToFlatten; - Set methodSignatureConstraintUebergabe; - //statistics - TypeUnify2Task(Set> setToFlatten, Set eq, - List>> oderConstraints, - Set nextSetElement, - IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModelParallel urm, - Set methodSignatureConstraintUebergabe, ConstraintSetRepository constraintSetRepository, Writer statistics) { - this(setToFlatten, eq, oderConstraints, nextSetElement, fc, parallel, logFile, log, rekTiefe, urm, methodSignatureConstraintUebergabe ); - - } - - public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModelParallel urm, Set methodSignatureConstraintUebergabe, ConstraintSetRepository constraintSetRepository) { - super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm); - this.setToFlatten = setToFlatten; - this.nextSetElement = nextSetElement; - this.methodSignatureConstraintUebergabe = methodSignatureConstraintUebergabe; - } - - Set getNextSetElement() { - return nextSetElement; - } - - @Override - protected Set> compute() { - if (one) { - System.out.println("two"); - } - one = true; - Set> res = new HashSet<>(); + Set> setToFlatten; + Set methodSignatureConstraintUebergabe; - if(!constraintSetRepository.containsSet(setToFlatten)){ - res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField, methodSignatureConstraintUebergabe); - } + //statistics + TypeUnify2Task(Set> setToFlatten, Set eq, + List>> oderConstraints, + Set nextSetElement, + IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModelParallel urm, + Set methodSignatureConstraintUebergabe, ConstraintSetRepository constraintSetRepository, Writer statistics) { + this(setToFlatten, eq, oderConstraints, nextSetElement, fc, parallel, logFile, log, rekTiefe, urm, methodSignatureConstraintUebergabe, constraintSetRepository); + + } + + public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModelParallel urm, Set methodSignatureConstraintUebergabe, ConstraintSetRepository constraintSetRepository) { + super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, constraintSetRepository); + this.setToFlatten = setToFlatten; + this.nextSetElement = nextSetElement; + this.methodSignatureConstraintUebergabe = methodSignatureConstraintUebergabe; + } + + Set getNextSetElement() { + return nextSetElement; + } + + @Override + protected Set> compute() { + if (one) { + System.out.println("two"); + } + one = true; + Set> res = new HashSet<>(); + + if (!constraintSetRepository.containsSet(setToFlatten)) { + res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField, methodSignatureConstraintUebergabe); + } /*if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } else - */ - //writeLog("xxx"); - //noOfThread--; - return res; - } - - public void closeLogFile() { + */ + //writeLog("xxx"); + //noOfThread--; + return res; + } - try { - logFile.close(); - } - catch (IOException ioE) { - System.err.println("no log-File" + thNo); - } - - } + public void closeLogFile() { + + try { + logFile.close(); + } catch (IOException ioE) { + System.err.println("no log-File" + thNo); + } + + } } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 50ae082..308c099 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -148,7 +148,7 @@ public class TypeUnifyTask extends RecursiveTask>> { //statistics public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModelParallel urm, ConstraintSetRepository constraintSetRepository, Writer statistics) { - this(eq,oderConstraints, fc, parallel, logFile, log, rekTiefe, urm); + this(eq,oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, constraintSetRepository); this.statistics = statistics; } public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModelParallel urm, ConstraintSetRepository constraintSetRepository) {