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%2FExternalReadEntry.java;h=2980b9b15f72e9a54b00a96fe06a397ef60b59b6;hp=661076e8604bacd47504ed86607df88bca54eee8;hb=HEAD;hpb=782843a248c4f70d28e8146098f9a77977cc6b3c diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java index 661076e86..2980b9b15 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java @@ -13,30 +13,32 @@ package org.simantics.db.impl.query; import java.util.LinkedList; +import org.simantics.databoard.Bindings; +import org.simantics.db.DevelopmentKeys; 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.procedure.Listener; import org.simantics.db.request.ExternalRead; import org.simantics.db.request.RequestFlags; +import org.simantics.utils.Development; final public class ExternalReadEntry extends CacheEntryBase> implements Listener { final LinkedList items = new LinkedList(); - protected ExternalRead request; - protected ReadGraphImpl graph; + protected ExternalRead id; + protected QueryProcessor processor; protected boolean registered = false; @Override int makeHash() { - return request.hashCode(); + return id.hashCode(); } @Override public Object getOriginalRequest() { - return request; + return id; } @Override @@ -45,14 +47,14 @@ final public class ExternalReadEntry extends CacheEntryBase @Override public void discard() { - request.unregistered(); - request = null; - graph = null; + id.unregistered(); + id = null; + processor = null; super.discard(); } @Override - public void setPending() { + public void setPending(QuerySupport querySupport) { //if(result != NO_RESULT) { //new Exception("result = " + result).printStackTrace(); //} @@ -62,14 +64,19 @@ final public class ExternalReadEntry extends CacheEntryBase public ExternalReadEntry(ExternalRead request, ReadGraphImpl graph) { assert request != null; - this.request = request; - this.graph = graph; + this.id = request; + this.processor = graph.processor; } @Override public void except(Throwable t) { - if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) { + System.err.println("[QUERY STATE]: excepted " + this); + } + } + if(statusOrException != DISCARDED) { statusOrException = EXCEPTED; result = t; @@ -112,7 +119,7 @@ final public class ExternalReadEntry extends CacheEntryBase } // Reschedule if(!items.isEmpty()) { - graph.processor.updatePrimitive(request); + graph.processor.updatePrimitive(id); } } @@ -131,8 +138,8 @@ final public class ExternalReadEntry extends CacheEntryBase @Override public String toString() { - if(request == null) return "DISCARDED ExternalRead"; - else return request.toString(); + if(id == null) return "DISCARDED ExternalRead"; + else return id.toString(); } }; @@ -141,8 +148,8 @@ final public class ExternalReadEntry extends CacheEntryBase @Override public String toString() { - if(request == null) return "DISCARDED ExternalRead " + System.identityHashCode(this); - else return request.toString() + " " + + System.identityHashCode(this); + if(id == null) return "DISCARDED ExternalRead " + System.identityHashCode(this); + else return id.toString() + " " + + System.identityHashCode(this); } @Override @@ -173,14 +180,14 @@ final public class ExternalReadEntry extends CacheEntryBase try { - ReadGraphImpl queryGraph = graph.withParent(this); + ReadGraphImpl queryGraph = graph.withParent(this, null, true); if(!registered) { - request.register(graph, this); + id.register(graph, this); registered = true; } - queryGraph.asyncBarrier.waitBarrier(request, graph); + queryGraph.asyncBarrier.waitBarrier(id, graph); } catch (Throwable t) { @@ -206,7 +213,7 @@ final public class ExternalReadEntry extends CacheEntryBase synchronized(items) { items.addLast(result); - graph.processor.updatePrimitive(request); + processor.updatePrimitive(id); // TODO: implement flags/logic in ExternalRead to state that all but the latest request result can be evaporated // In some cases where data is produced really fast this might be necessary but currently this queueing will do. } @@ -222,7 +229,12 @@ final public class ExternalReadEntry extends CacheEntryBase @Override public boolean isDisposed() { - return registered && (isDiscarded() || !graph.processor.isBound(this)); + return registered && (isDiscarded() || !processor.isBound(this)); } - + + @Override + public String classId() { + return null; + } + }