X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FAsyncReadEntry.java;h=8e6cbd145a78d9a1aacf3b99f20c396a789beaae;hb=ded784594eb0e1fb318fbb931135288152691cf2;hp=767a82bd5644e8759a282b8820c49b570a8fdd60;hpb=ad18bf76b19bec530bc68c6041ab5fb245b8ee4d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java index 767a82bd5..8e6cbd145 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java @@ -144,9 +144,85 @@ final public class AsyncReadEntry extends CacheEntryBase> { @Override public Object compute(ReadGraphImpl graph, AsyncProcedure procedure) throws DatabaseException { - return graph.processor.cache.performQuery(graph, request, this, procedure); + + ReadGraphImpl queryGraph = graph.withParent(this); + + request.perform(queryGraph, new AsyncProcedure() { + + @Override + public void execute(AsyncReadGraph returnGraph, T result) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + AsyncReadEntry.this.addOrSet(graph, result); + try { + procedure.execute(graph, result); + } catch (Throwable t) { + t.printStackTrace(); + } + // parentBarrier.dec(query); + } + + @Override + public void exception(AsyncReadGraph returnGraph, Throwable t) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + // AsyncReadGraph resumeGraph = finalParentGraph.newAsync(); + AsyncReadEntry.this.except(graph, t); + try { + procedure.exception(graph, t); + } catch (Throwable t2) { + t2.printStackTrace(); + } + // parentBarrier.dec(query); + } + + @Override + public String toString() { + return procedure.toString(); + } + + }); + + return getResult(); + + } + + public static void computeForEach(ReadGraphImpl parentGraph, AsyncRead request, AsyncReadEntry entry, AsyncProcedure procedure) throws DatabaseException { + + ReadGraphImpl queryGraph = parentGraph.withParent(entry); + + request.perform(queryGraph, new AsyncProcedure() { + + @Override + public void execute(AsyncReadGraph returnGraph, T result) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + if(entry != null) entry.addOrSet(parentGraph, result); + try { + procedure.execute(parentGraph, result); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void exception(AsyncReadGraph returnGraph, Throwable t) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + if(entry != null) entry.except(parentGraph, t); + try { + procedure.exception(parentGraph, t); + } catch (Throwable t2) { + t2.printStackTrace(); + } + } + + @Override + public String toString() { + return procedure.toString(); + } + + }); + } + @Override public String toString() { if(isDiscarded()) return "DISCARDED " + request.toString();