X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FReadEntry.java;h=1ceca45a5a0cec7371f632941a13b3c1610fc60a;hp=61e934fe9cc59f7458aa8f247e8652c280006a89;hb=4c5ff8ec11947aae4d49106365819717cfa43209;hpb=ec70c03d4ce3f68b71de5eeadce3d008620c5521 diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ReadEntry.java index 61e934fe9..1ceca45a5 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ReadEntry.java @@ -101,29 +101,49 @@ public final class ReadEntry extends CacheEntryBase> implem AsyncProcedure procedure = entry != null ? entry : procedure_; ReadGraphImpl queryGraph = graph.withParent(entry); + queryGraph.asyncBarrier.inc(); + ReadGraphImpl executeGraph = graph.withParent(graph.parent); + executeGraph.asyncBarrier.inc(); + try { + // This throws T result = request.perform(queryGraph); - if(procedure != null) procedure.execute(graph, result); + + if(procedure != null) procedure.execute(executeGraph, result); return (T)result; } catch (DatabaseException e) { - if(procedure != null) procedure.exception(graph, e); + if(procedure != null) procedure.exception(executeGraph, e); throw e; } catch (Throwable t) { DatabaseException dbe = new DatabaseException(t); - if(procedure != null) procedure.exception(graph, dbe); + if(procedure != null) procedure.exception(executeGraph, dbe); throw dbe; } finally { - if (entry != null) - entry.performFromCache(queryGraph, procedure_); + queryGraph.asyncBarrier.dec(); + + try { + + if (entry != null) { + // This also throws so must dec barrier finally + entry.performFromCache(executeGraph, procedure_); + } + + } finally { + + executeGraph.asyncBarrier.dec(); + executeGraph.asyncBarrier.waitBarrier(procedure, executeGraph); + } + + } }