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(graph, result);
+
+ if(procedure != null) procedure.execute(executeGraph, result);
return (T)result;
} catch (DatabaseException e) {
- if(procedure != null) procedure.exception(graph, e);
+ if(procedure != null) procedure.exception(executeGraph, e);
throw e;
} catch (Throwable t) {
DatabaseException dbe = new DatabaseException(t);
- if(procedure != null) procedure.exception(graph, dbe);
+ if(procedure != null) procedure.exception(executeGraph, dbe);
throw dbe;
} finally {
- if (entry != null)
- entry.performFromCache(queryGraph, procedure_);
+ queryGraph.asyncBarrier.dec();
+
+ try {
+
+ if (entry != null) {
+ // This also throws so must dec barrier finally
+ entry.performFromCache(executeGraph, procedure_);
+ }
+
+ } finally {
+
+ executeGraph.asyncBarrier.dec();
+ executeGraph.asyncBarrier.waitBarrier(procedure, executeGraph);
+ }
+
+
}
}