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=767a82bd5644e8759a282b8820c49b570a8fdd60;hb=ad18bf76b19bec530bc68c6041ab5fb245b8ee4d;hp=2410dfad7cf3b7c1e1c4bd26eca52e53a45ffd6a;hpb=e3290cc52342e783a2617f3009fff8e6f3e54560;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 2410dfad7..767a82bd5 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 @@ -12,16 +12,17 @@ package org.simantics.db.impl.query; import org.simantics.db.AsyncReadGraph; +import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.db.request.AsyncRead; -final public class AsyncReadEntry extends CacheEntryBase { +final public class AsyncReadEntry extends CacheEntryBase> { protected AsyncRead request; - public AsyncReadEntry(AsyncRead request) { + AsyncReadEntry(AsyncRead request) { this.request = request; if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: created " + this); } @@ -39,31 +40,17 @@ final public class AsyncReadEntry extends CacheEntryBase { @Override public void discard() { super.discard(); - //request = null; setResult(null); } final public void addOrSet(AsyncReadGraph graph, Object item) { assert(isPending()); - -// ArrayList> p = null; synchronized(this) { - setResult(item); setReady(); -// p = procs; -// procs = null; - } - -// if(p != null) -// for(AsyncProcedure proc : p) { -// proc.execute(graph, (T)item); -//// proc.first.execute(graph, (T)item); -//// proc.second.dec(); -// } } @@ -71,21 +58,10 @@ final public class AsyncReadEntry extends CacheEntryBase { public void except(AsyncReadGraph graph, Throwable t) { assert(isPending()); - -// ArrayList> p = null; synchronized(this) { - except(t); -//// p = procs; -// procs = null; - } - -// if(p != null) -// for(AsyncProcedure proc : p) { -// proc.exception(graph, t); -// } } @@ -96,15 +72,11 @@ final public class AsyncReadEntry extends CacheEntryBase { return new Query() { @Override - public void recompute(ReadGraphImpl graph, Object provider, CacheEntry entry) { - - QueryProcessor qp = (QueryProcessor)provider; - - final ReadGraphImpl parentGraph = ReadGraphImpl.forRecompute(entry, qp); + public void recompute(ReadGraphImpl graph) { try { - request.perform(parentGraph , new AsyncProcedure() { + request.perform(graph , new AsyncProcedure() { @Override public void execute(AsyncReadGraph graph, T result) { @@ -126,7 +98,7 @@ final public class AsyncReadEntry extends CacheEntryBase { @Override public void removeEntry(QueryProcessor qp) { - qp.cache.asyncReadMap.remove(request); + qp.cache.remove(AsyncReadEntry.this); } @Override @@ -145,15 +117,9 @@ final public class AsyncReadEntry extends CacheEntryBase { } -<<<<<<< HEAD - @SuppressWarnings("unchecked") - public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) { -======= - public Object performFromCache(ReadGraphImpl graph, Object provider, Object procedure) { ->>>>>>> refs/heads/db-threads + @Override + public Object performFromCache(ReadGraphImpl graph, AsyncProcedure proc) { - AsyncProcedure proc = (AsyncProcedure)procedure; - if(isExcepted()) { try { @@ -176,6 +142,11 @@ 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); + } + @Override public String toString() { if(isDiscarded()) return "DISCARDED " + request.toString();