+// public <T> void performForEach(final ReadGraphImpl graph, final MultiRead<T> query, final MultiReadEntry<T> entry, CacheEntry parent, final ListenerBase listener, final AsyncMultiProcedure<T> procedure,
+// boolean inferredDependency) {
+//
+// if (DebugPolicy.PERFORM)
+// System.out.println("PE[ " + (query.hashCode() & THREAD_MASK) + "] " + query);
+//
+// assert (!dirty);
+// assert (!collecting);
+//
+// assert(!entry.isPending());
+// assert(!entry.isDiscarded());
+//
+// // FRESH, REFUTED, EXCEPTED go here
+// if (!entry.isReady()) {
+//
+// entry.setPending();
+// entry.clearResult();
+//
+// multiReadMap.put(query, entry);
+// size++;
+//
+// final ReadGraphImpl newGraph = graph.newSync(entry);
+//// newGraph.state.barrier.inc();
+//
+// try {
+//
+// query.perform(newGraph, new AsyncMultiProcedure<T>() {
+//
+// @Override
+// public void execute(AsyncReadGraph graph, T result) {
+// entry.addOrSet(result);
+// try {
+// procedure.execute(graph, result);
+// } catch (Throwable t) {
+// t.printStackTrace();
+// }
+// }
+//
+// @Override
+// public void finished(AsyncReadGraph graph) {
+// entry.finish(graph);
+// try {
+// procedure.finished(graph);
+// } catch (Throwable t) {
+// t.printStackTrace();
+// }
+//// newGraph.state.barrier.dec();
+//// parentBarrier.dec();
+// }
+//
+// @Override
+// public void exception(AsyncReadGraph graph, Throwable t) {
+// entry.except(t);
+// try {
+// procedure.exception(graph, t);
+// } catch (Throwable t2) {
+// t2.printStackTrace();
+// }
+//// newGraph.state.barrier.dec();
+//// parentBarrier.dec();
+// }
+//
+// });
+//
+// } catch (DatabaseException e) {
+//
+// entry.except(e);
+// try {
+// procedure.exception(graph, e);
+// } catch (Throwable t2) {
+// t2.printStackTrace();
+// }
+//// newGraph.state.barrier.dec();
+//// parentBarrier.dec();
+//
+// } catch (Throwable t) {
+//
+// DatabaseException e = new DatabaseException(t);
+//
+// entry.except(e);
+// try {
+// procedure.exception(graph, e);
+// } catch (Throwable t2) {
+// t2.printStackTrace();
+// }
+//// newGraph.state.barrier.dec();
+//// parentBarrier.dec();
+//
+// }
+//
+// misses++;
+//
+// } else {
+//
+// entry.performFromCache(graph, this, procedure);
+// hits++;
+//
+//
+// }
+//
+// assert (!entry.isDiscarded());
+//
+// registerDependencies(graph, entry, parent, listener, procedure, inferredDependency);
+//
+// }
+//
+//
+// public <T> void performForEach(final ReadGraphImpl callerGraph, AsyncMultiRead<T> query, final AsyncMultiReadEntry<T> entry, final CacheEntry parent, final ListenerBase listener, final AsyncMultiProcedure<T> procedure,
+// boolean inferredDependency) {
+//
+// if (DebugPolicy.PERFORM)
+// System.out.println("PE[ " + (query.hashCode() & THREAD_MASK) + "] " + query);
+//
+// assert (!dirty);
+// assert (!collecting);
+//
+// try {
+//
+// assert(!entry.isDiscarded());
+//
+// // FRESH, REFUTED, EXCEPTED go here
+// if (!entry.isReady()) {
+//
+// size++;
+//
+// try {
+//
+// ReadGraphImpl performGraph = callerGraph.withAsyncParent(entry);
+//
+// query.perform(performGraph, new AsyncMultiProcedure<T>() {
+//
+// @Override
+// public void execute(AsyncReadGraph graph, T result) {
+// ReadGraphImpl impl = (ReadGraphImpl)graph;
+//// ReadGraphImpl executeGraph = callerGraph.newAsync();
+// entry.addOrSet(result);
+// try {
+// procedure.execute(callerGraph, result);
+// } catch (Throwable t) {
+// t.printStackTrace();
+// }
+// }
+//
+// @Override
+// public void finished(AsyncReadGraph graph) {
+// ReadGraphImpl impl = (ReadGraphImpl)graph;
+//// ReadGraphImpl executeGraph = callerGraph.newAsync();
+// entry.finish(callerGraph);
+// try {
+// procedure.finished(callerGraph);
+// } catch (Throwable t) {
+// t.printStackTrace();
+// }
+// }
+//
+// @Override
+// public void exception(AsyncReadGraph graph, Throwable t) {
+// ReadGraphImpl impl = (ReadGraphImpl)graph;
+//// ReadGraphImpl executeGraph = callerGraph.newAsync();
+// entry.except(callerGraph, t);
+// try {
+// procedure.exception(callerGraph, t);
+// } catch (Throwable t2) {
+// t2.printStackTrace();
+// }
+// }
+//
+// });
+//
+// } catch (Throwable t) {
+//
+// entry.except(t);
+// try {
+// procedure.exception(callerGraph, t);
+// } catch (Throwable t2) {
+// t2.printStackTrace();
+// }
+//
+// }
+//
+//
+// misses++;
+//
+// } else {
+//
+// entry.performFromCache(callerGraph, this, procedure);
+//
+// hits++;
+//
+// }
+//
+// assert (!entry.isDiscarded());
+//
+// registerDependencies(callerGraph, entry, parent, listener, procedure, inferredDependency);
+//
+// } catch (Throwable t) {
+//
+// Logger.defaultLogError(t);
+//
+// } finally {
+//
+// }
+//
+// }
+//
+// public <T> void performForEach(ReadGraphImpl graph, final ExternalRead<T> query, final ExternalReadEntry<T> entry, final CacheEntry parent, final ListenerBase base, final Procedure<T> procedure,
+// boolean inferredDependency) {
+//
+// if (DebugPolicy.PERFORM)
+// System.out.println("PE[ " + (query.hashCode() & THREAD_MASK) + "] " + query);
+//
+// assert (!dirty);
+// assert (!collecting);
+//
+// assert(!entry.isPending());
+// assert(!entry.isDiscarded());
+//
+// registerDependencies(graph, entry, parent, base, procedure, inferredDependency);
+//
+// // FRESH, REFUTED, EXCEPTED go here
+// if (!entry.isReady()) {
+//
+// entry.setPending();
+// entry.clearResult(querySupport);
+//
+// externalReadMap.put(query, entry);
+// size++;
+//
+// try {
+//
+// query.register(graph, new Listener<T>() {
+//
+// AtomicBoolean used = new AtomicBoolean(false);
+//
+// @Override
+// public void execute(T result) {
+//
+// // Just for safety
+// if(entry.isDiscarded()) return;
+// if(entry.isExcepted()) entry.setPending();
+//
+// if(used.compareAndSet(false, true)) {
+// entry.addOrSet(QueryProcessor.this, result);
+// procedure.execute(result);
+// } else {