From: Reino Ruusu Date: Tue, 25 Feb 2020 14:09:27 +0000 (+0200) Subject: Block parallel execution of position updates and validation. X-Git-Tag: v1.43.0~58 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1f7b0edd896d1a274f1cd7d545d4360993c26c7c;p=simantics%2F3d.git Block parallel execution of position updates and validation. gitlab #92 Change-Id: I591afd4ee115a322e4edd6ad87aa3da89c453f9a --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java index b2376341..8864ffd8 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java @@ -68,11 +68,12 @@ public class PipingRules { if (!PipingRules.enabled) return false; - if (requestUpdates.size() == 0) - return false; - - List temp = new ArrayList(requestUpdates.size()); - synchronized(updateMutex) { + List temp; + synchronized(updateMutex) { + if (requestUpdates.size() == 0) + return false; + + temp = new ArrayList(requestUpdates.size()); temp.addAll(requestUpdates); requestUpdates.clear(); } @@ -2075,50 +2076,52 @@ public class PipingRules { public static void validate(PipeRun pipeRun) { if (pipeRun == null) return; - Collection pcps = pipeRun.getControlPoints(); - int count = 0; - //System.out.println("Validate " + pipeRun.getName()); - for (PipeControlPoint pcp : pcps) { - if (pcp.getParentPoint() == null || pcp.getParentPoint().getPipeRun() != pipeRun) - count++; - } - List runPcps = getControlPoints(pipeRun); - if (runPcps.size() != count) { - System.out.println("Run " + pipeRun.getName() + " contains unconnected control points, found " + runPcps.size() + " connected, " + pcps.size() + " total."); + synchronized (ruleMutex) { + Collection pcps = pipeRun.getControlPoints(); + int count = 0; + //System.out.println("Validate " + pipeRun.getName()); for (PipeControlPoint pcp : pcps) { - if (!runPcps.contains(pcp)) { - System.out.println("Unconnected " + pcp + " " + pcp.getPipelineComponent()); - } + if (pcp.getParentPoint() == null || pcp.getParentPoint().getPipeRun() != pipeRun) + count++; } - } - for (PipeControlPoint pcp : pcps) { - if (pcp.getPipeRun() == null) { - System.out.println("PipeRun ref missing " + pcp + " " + pcp.getPipelineComponent()); - } - if (!pcp.isDirected() && pcp.getNext() == null && pcp.getPrevious() == null) - System.out.println("Orphan undirected " + pcp + " " + pcp.getPipelineComponent()); - } - for (PipeControlPoint pcp : pcps) { - if (pcp.getParentPoint() == null) { - PipeControlPoint sub = null; - if (pcp.isDualInline()) - sub = pcp.getDualSub(); - PipeControlPoint next = pcp.getNext(); - PipeControlPoint prev = pcp.getPrevious(); - if (next != null) { - if (!(next.getPrevious() == pcp || next.getPrevious() == sub)) { - System.out.println("Inconsistency between " + pcp + " -> " +next ); - } + List runPcps = getControlPoints(pipeRun); + if (runPcps.size() != count) { + System.out.println("Run " + pipeRun.getName() + " contains unconnected control points, found " + runPcps.size() + " connected, " + pcps.size() + " total."); + for (PipeControlPoint pcp : pcps) { + if (!runPcps.contains(pcp)) { + System.out.println("Unconnected " + pcp + " " + pcp.getPipelineComponent()); + } } - if (prev != null) { - PipeControlPoint prevParent = null; - if (prev.isDualSub()) { - prevParent = prev.getParentPoint(); - } else if (prev.isDualInline()) { - System.out.println("Inconsistency between " + pcp + " <-- " +prev ); + } + for (PipeControlPoint pcp : pcps) { + if (pcp.getPipeRun() == null) { + System.out.println("PipeRun ref missing " + pcp + " " + pcp.getPipelineComponent()); + } + if (!pcp.isDirected() && pcp.getNext() == null && pcp.getPrevious() == null) + System.out.println("Orphan undirected " + pcp + " " + pcp.getPipelineComponent()); + } + for (PipeControlPoint pcp : pcps) { + if (pcp.getParentPoint() == null) { + PipeControlPoint sub = null; + if (pcp.isDualInline()) + sub = pcp.getDualSub(); + PipeControlPoint next = pcp.getNext(); + PipeControlPoint prev = pcp.getPrevious(); + if (next != null) { + if (!(next.getPrevious() == pcp || next.getPrevious() == sub)) { + System.out.println("Inconsistency between " + pcp + " -> " +next ); + } } - if (!(prev.getNext() == pcp && (prevParent == null || prevParent.getNext() == pcp))) { - System.out.println("Inconsistency between " + pcp + " <-- " +prev ); + if (prev != null) { + PipeControlPoint prevParent = null; + if (prev.isDualSub()) { + prevParent = prev.getParentPoint(); + } else if (prev.isDualInline()) { + System.out.println("Inconsistency between " + pcp + " <-- " +prev ); + } + if (!(prev.getNext() == pcp && (prevParent == null || prevParent.getNext() == pcp))) { + System.out.println("Inconsistency between " + pcp + " <-- " +prev ); + } } } }