X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2FBlockingAsyncProcedure.java;h=2d3e2804c6ebf4d630984892195c6fe2e2e4b0fa;hb=199e71d04a503618e59a1667ea3abee36be08732;hp=ad9f1643829fe506ac57125edaf2bc724a249d05;hpb=277b1c7fb3fdd8effb4bf2b447358d0e4ef0e302;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/BlockingAsyncProcedure.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/BlockingAsyncProcedure.java index ad9f16438..2d3e2804c 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/BlockingAsyncProcedure.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/BlockingAsyncProcedure.java @@ -14,6 +14,7 @@ package org.simantics.db.impl; import org.simantics.db.AsyncReadGraph; import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.impl.graph.AsyncBarrierImpl; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.procedure.AsyncProcedure; @@ -22,50 +23,53 @@ public class BlockingAsyncProcedure implements AsyncProcedure { private static final Object NO_RESULT = new Object(); private final Object key; - private final ReadGraphImpl graph; + private final AsyncBarrierImpl barrier; + private final ReadGraphImpl procedureGraph; private final AsyncProcedure procedure; private Object result = NO_RESULT; private Throwable exception = null; - public BlockingAsyncProcedure(ReadGraphImpl graph, AsyncProcedure procedure, Object key) { + public BlockingAsyncProcedure(AsyncBarrierImpl barrier, ReadGraphImpl procedureGraph, AsyncProcedure procedure, Object key) { this.procedure = procedure; this.key = key; - this.graph = graph; - this.graph.asyncBarrier.inc(); + this.barrier = barrier; + this.barrier.inc(); + this.procedureGraph = procedureGraph; } @Override - public void execute(AsyncReadGraph graph, Result result) { + public void execute(AsyncReadGraph graph_, Result result) { this.result = result; - this.graph.asyncBarrier.dec(); try { - if(procedure != null) procedure.execute(graph, result); + if(procedure != null) procedure.execute(procedureGraph, result); } catch (Throwable throwable) { Logger.defaultLogError("AsyncProcedure.execute threw for " + procedure, throwable); + } finally { + barrier.dec(); } } @Override - public void exception(AsyncReadGraph graph, Throwable t) { + public void exception(AsyncReadGraph graph_, Throwable t) { this.exception = t; try { - if(procedure != null) procedure.exception(graph, t); + if(procedure != null) procedure.exception(procedureGraph, t); } catch (Throwable throwable) { Logger.defaultLogError("AsyncProcedure.exception threw for " + procedure, throwable); } finally { - this.graph.asyncBarrier.dec(); + barrier.dec(); } } public void waitBarrier() { - graph.asyncBarrier.waitBarrier(key, graph); + barrier.waitBarrier(key, procedureGraph); } @SuppressWarnings("unchecked") public Result get() throws DatabaseException { - graph.asyncBarrier.waitBarrier(key, graph); + barrier.waitBarrier(key, procedureGraph); if(exception != null) { if(exception instanceof DatabaseException) throw (DatabaseException)exception; @@ -77,7 +81,7 @@ public class BlockingAsyncProcedure implements AsyncProcedure { } public boolean isDone() { - return graph.asyncBarrier.get() == 0; + return barrier.get() == 0; } @SuppressWarnings("unchecked")