- final static Objects entry(final QueryProcessor provider, final int r1, final int r2) {
- return (Objects)provider.objectsMap.get(r1,r2);
- }
-
- final static Collection<Objects> entries(final QueryProcessor processor, final int r1) {
- return processor.objectsMap.values(r1);
- }
-
- public final static void runner(ReadGraphImpl graph, final int r1, final int r2, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) {
-
- if(parent == null && listener == null) {
- Objects.computeForEach(graph, r1, r2, null, procedure);
- return;
- }
-
- QueryProcessor processor = graph.processor;
-
- Objects entry = (Objects)processor.objectsMap.get(r1,r2);
- if(entry == null) {
-
- entry = new Objects(r1, r2);
- entry.setPending();
- entry.clearResult(processor.querySupport);
- entry.putEntry(processor);
-
- processor.performForEach(graph, entry, parent, listener, procedure);
-
- } else {
-
- if(entry.isPending()) {
- synchronized(entry) {
- if(entry.isPending()) {
- processor.registerDependencies(graph, entry, parent, listener, procedure, false);
- computeForEach(graph, r1, r2, null, procedure);
- return;
- }
- }
- }
-
- processor.performForEach(graph, entry, parent, listener, procedure);
-
- }
-
- }
-
- static class Runner2Procedure implements IntProcedure {
-
- public int single = 0;
- public Throwable t = null;
-
- public void clear() {
- single = 0;
- t = null;
- }
-
- @Override
- public void execute(ReadGraphImpl graph, int i) {
- if(single == 0) single = i;
- else single = -1;
- }
-
- @Override
- public void finished(ReadGraphImpl graph) {
- if(single == -1) single = 0;
- }
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- single = 0;
- this.t = throwable;
- }
-
- public int get() throws DatabaseException {
- if(t != null) {
- if(t instanceof DatabaseException) throw (DatabaseException)t;
- else throw new DatabaseException(t);
- }
- return single;
- }
-
- }
-
- static final Runner2Procedure runner2Procedure = new Runner2Procedure();
-
- public final static int runner2(ReadGraphImpl graph, final int r1, final int r2, CacheEntry parent) throws DatabaseException {
-
- runner2Procedure.clear();
-
- if(parent == null) {
- Objects.computeForEach(graph, r1, r2, null, runner2Procedure);
- return runner2Procedure.get();
- }
-
- QueryProcessor processor = graph.processor;
-
- Objects entry = (Objects)processor.objectsMap.get(r1,r2);
- if(entry == null) {
-
- entry = new Objects(r1, r2);
- entry.setPending();
- entry.clearResult(processor.querySupport);
- entry.putEntry(processor);
-
- processor.performForEach(graph, entry, parent, null, runner2Procedure);
- return runner2Procedure.get();
-
- } else {
-
- if(entry.isPending()) throw new IllegalStateException();
-
- processor.performForEach(graph, entry, parent, null, runner2Procedure);
- return runner2Procedure.get();
-
- }
-
- }
-
- @Override
- public BinaryQuery<IntProcedure> getEntry(QueryProcessor provider) {
- return provider.objectsMap.get(id);
- }
-
- @Override
- public void putEntry(QueryProcessor provider) {
- if(Development.DEVELOPMENT) {
- if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_PUT, Bindings.BOOLEAN)) {
- System.err.println("put " + this);
- }
- }
- provider.objectsMap.put(id, this);
- }
-