+
+ return getResult();
+
+ }
+
+ public static <T> void computeForEach(ReadGraphImpl parentGraph, AsyncRead<T> request, AsyncReadEntry<T> entry,
+ AsyncProcedure<T> procedure_) throws DatabaseException {
+
+ AsyncProcedure<T> procedure = entry != null ? entry : procedure_;
+
+ ReadGraphImpl queryGraph = parentGraph.withParent(entry);
+
+ BlockingAsyncProcedure<T> proc = new BlockingAsyncProcedure<>(queryGraph, new AsyncProcedure<T>() {
+
+ @Override
+ public void execute(AsyncReadGraph returnGraph, T result) {
+ try {
+ procedure.execute(parentGraph, result);
+ } catch (Throwable t) {
+ LOGGER.error("computeForEach procedure.execute failed", t);
+ }
+ }
+
+ @Override
+ public void exception(AsyncReadGraph returnGraph, Throwable t) {
+ try {
+ procedure.exception(parentGraph, t);
+ } catch (Throwable t2) {
+ LOGGER.error("computeForEach procedure.exception failed", t2);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return procedure.toString();
+ }
+
+ }, request);
+
+ request.perform(queryGraph, proc);
+
+ proc.get();
+
+ if (entry != null)
+ entry.performFromCache(parentGraph, procedure_);
+
+ }
+
+ @Override
+ public String toString() {
+ if (isDiscarded())
+ return "DISCARDED " + request.toString();
+ else if (isExcepted())
+ return request.toString() + " " + getResult();
+ else
+ return request.toString() + " " + statusOrException;
+ }
+
+ @Override
+ public void execute(AsyncReadGraph graph, T result) {
+ setResult(result);
+ setReady();
+ }
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ except(throwable);
+ }