import org.simantics.db.AsyncReadGraph;
import org.simantics.db.common.exception.DebugException;
+import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.graph.ReadGraphImpl;
import org.simantics.db.impl.query.QueryProcessor.AsyncBarrier;
import org.simantics.db.procedure.AsyncMultiProcedure;
import org.simantics.db.request.RequestFlags;
import org.simantics.utils.datastructures.Pair;
-final public class MultiReadEntry<T> extends CacheEntryBase {
-
-// public ArrayList<Pair<AsyncMultiProcedure<T>, AsyncBarrier>> procs;
+final public class MultiReadEntry<T> extends CacheEntryBase<AsyncMultiProcedure<T>> {
protected MultiRead<T> request;
- public MultiReadEntry(MultiRead<T> request) {
+ MultiReadEntry(MultiRead<T> request) {
this.request = request;
}
ArrayList<Pair<AsyncMultiProcedure<T>, AsyncBarrier>> p = null;
synchronized(this) {
-
setReady();
-
-// p = procs;
-// procs = null;
-
}
-// if(p != null) {
-// ArrayList<T> v = (ArrayList<T>)getResult();
-// if(v != null) {
-// for(Pair<AsyncMultiProcedure<T>, AsyncBarrier> pair : p) {
-// for(T t : v) pair.first.execute(graph, t);
-// }
-// }
-// for(Pair<AsyncMultiProcedure<T>, AsyncBarrier> pair : p) {
-// pair.first.finished(graph);
-// pair.second.dec();
-// }
-// }
-
}
@Override
return new Query() {
@Override
- public void recompute(ReadGraphImpl graph, Object provider, CacheEntry entry) {
+ public void recompute(ReadGraphImpl graph) {
- QueryProcessor qp = (QueryProcessor)provider;
-
- final ReadGraphImpl parentGraph = ReadGraphImpl.forRecompute(entry, qp);
-// parentGraph.state.barrier.inc();
-
try {
- request.perform(parentGraph , new AsyncMultiProcedure<T>() {
+ request.perform(graph , new AsyncMultiProcedure<T>() {
@Override
public void execute(AsyncReadGraph graph, T result) {
addOrSet(result);
-// parentGraph.state.barrier.dec();
}
public void finished(AsyncReadGraph graph) {
finish(graph);
-// parentGraph.state.barrier.dec();
};
@Override
public void exception(AsyncReadGraph graph, Throwable t) {
except(t);
-// parentGraph.state.barrier.dec();
}
});
-// parentGraph.waitAsync(request);
-
} catch (Throwable t) {
except(t);
-// parentGraph.state.barrier.dec();
if(DebugException.DEBUG) new DebugException(t).printStackTrace();
}
@Override
public void removeEntry(QueryProcessor processor) {
- processor.cache.multiReadMap.remove(request);
+ processor.cache.remove(MultiReadEntry.this);
}
@Override
}
@Override
- public Object performFromCache(ReadGraphImpl graph, Object provider,
- Object procedure) {
+ public Object performFromCache(ReadGraphImpl graph, AsyncMultiProcedure<T> proc) {
- final AsyncMultiProcedure<T> proc = (AsyncMultiProcedure<T>)procedure;
-
if(isExcepted()) {
try {
else return request.toString() + statusOrException;
}
+ @Override
+ public Object compute(ReadGraphImpl graph, AsyncMultiProcedure<T> procedure) throws DatabaseException {
+ return graph.processor.cache.performQuery(graph, request, this, procedure);
+ }
+
}