+
+ @Override
+ public void run() {
+
+ AsyncProcedure<Result> procedure__ = entry != null ? entry : procedure;
+
+ ReadGraphImpl executeGraph = callerGraph.withParent(callerGraph.parent, null, needsToBlock);
+ executeGraph.asyncBarrier.inc();
+
+ // This counters the inc in the constructor
+ callerGraph.asyncBarrier.dec();
+
+ try {
+ if(procedure__ != null) {
+ procedure__.execute(executeGraph, get());
+ }
+ } catch (DatabaseException e) {
+ if(procedure__ != null) procedure__.exception(executeGraph, e);
+ exception = e;
+ } catch (Throwable t) {
+ DatabaseException dbe = new DatabaseException(t);
+ if(procedure__ != null) procedure__.exception(executeGraph, dbe);
+ exception = dbe;
+ } finally {
+
+ if (entry != null) {
+ assert(entry.isReady());
+ // This does not throw
+ entry.performFromCache(executeGraph, procedure);
+ }
+
+ executeGraph.asyncBarrier.dec();
+ if(needsToBlock)
+ executeGraph.asyncBarrier.waitBarrier(procedure__, executeGraph);
+ }
+
+ if (BarrierTracing.BOOKKEEPING) {
+ BarrierTracing.unregisterBAP(this);
+ }
+
+ }
+
+ public void print() {
+ System.err.println("BlockingAsyncProcedure");
+ System.err.println("-key: " + key);
+ System.err.println("-queryGraph: " + queryGraph);
+ System.err.println("-callerGraph: " + callerGraph);
+ System.err.println("-procedure: " + procedure);
+ System.err.println("-pendingTaskSupport: " + pendingTaskSupport);
+ System.err.println("-result: " + result);
+ System.err.println("-exception: " + exception);
+ }
+
+ public Result performSync(AsyncRead<Result> request) throws DatabaseException {
+ try {
+ request.perform(queryGraph, this);
+ } finally {
+ dec();
+ }
+ return get();
+ }
+
+ public void performAsync(AsyncRead<Result> request) throws DatabaseException {
+ try {
+ request.perform(queryGraph, this);
+ } finally {
+ dec();
+ }
+ }