+
+ }
+
+ 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_;
+
+ GraphSemaphore s = new GraphSemaphore(parentGraph, 0);
+
+ ReadGraphImpl queryGraph = parentGraph.withParent(entry);
+
+ request.perform(queryGraph, new AsyncProcedure<T>() {
+
+ @Override
+ public void execute(AsyncReadGraph returnGraph, T result) {
+ try {
+ procedure.execute(parentGraph, result);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ s.release();
+ }
+
+ @Override
+ public void exception(AsyncReadGraph returnGraph, Throwable t) {
+ try {
+ procedure.exception(parentGraph, t);
+ } catch (Throwable t2) {
+ t2.printStackTrace();
+ }
+ s.release();
+ }
+
+ @Override
+ public String toString() {
+ return procedure.toString();
+ }
+
+ });
+
+ try {
+ s.waitFor(1);
+ } catch (InterruptedException e) {
+ throw new RuntimeDatabaseException(e);