+ public static <T> T computeForEach(ReadGraphImpl graph, Read<T> request, ReadEntry<T> entry,
+ AsyncProcedure<T> procedure_, boolean needsToBlock) throws DatabaseException {
+
+ AsyncProcedure<T> procedure = entry != null ? entry : procedure_;
+
+ ReadGraphImpl queryGraph = graph.withParent(entry);
+ queryGraph.asyncBarrier.inc();
+
+ ReadGraphImpl executeGraph = graph.withParent(graph.parent);
+ executeGraph.asyncBarrier.inc();
+
+ try {
+
+ // This throws
+ T result = request.perform(queryGraph);
+
+ if(procedure != null) procedure.execute(executeGraph, result);
+ return (T)result;
+
+ } catch (DatabaseException e) {
+
+ if(procedure != null) procedure.exception(executeGraph, e);
+ throw e;
+
+ } catch (Throwable t) {
+
+ DatabaseException dbe = new DatabaseException(t);
+ if(procedure != null) procedure.exception(executeGraph, dbe);
+ throw dbe;
+
+ } finally {
+
+ queryGraph.asyncBarrier.dec();