import org.simantics.db.authentication.UserAuthenticator;
import org.simantics.db.common.Indexing;
import org.simantics.db.common.TransactionPolicyRelease;
+import org.simantics.db.common.procedure.BlockingAsyncProcedure;
import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;
import org.simantics.db.common.procedure.adapter.ProcedureAdapter;
import org.simantics.db.common.procedure.wrapper.NoneToAsyncListener;
import org.simantics.db.impl.procedure.ResultCallWrappedQueryProcedure4;
import org.simantics.db.impl.procedure.ResultCallWrappedSingleQueryProcedure4;
import org.simantics.db.impl.query.QueryCache;
+import org.simantics.db.impl.query.QueryCacheBase;
import org.simantics.db.impl.query.QueryProcessor;
import org.simantics.db.impl.query.QueryProcessor.SessionRead;
import org.simantics.db.impl.query.QueryProcessor.SessionTask;
assert (request != null);
assert (procedure != null);
- int thread = request.hashCode() & queryProvider2.THREAD_MASK;
+ //int thread = request.hashCode() & queryProvider2.THREAD_MASK;
- requestManager.scheduleRead(new SessionRead(request, throwable, notify, thread, thread) {
+ requestManager.scheduleRead(new SessionRead(request, throwable, notify, queryProvider2.THREAD_MASK + 1, -1) {
@Override
public void run(int thread) {
};
- QueryCache.runnerReadEntry(newGraph, request, null, listener, ap);
+ QueryCache.runnerReadEntry(newGraph, request, null, listener, ap, true);
} catch (Throwable t) {
// This is handled by the AsyncProcedure
if (listener != null) {
try {
- QueryCache.runnerAsyncReadEntry(newGraph, request, null, listener, procedure);
+ QueryCacheBase.resultAsyncReadEntry(newGraph, request, null, listener, procedure);
+ //QueryCache.runnerAsyncReadEntry(newGraph, request, null, listener, procedure, true);
//newGraph.processor.query(newGraph, request, null, procedure, listener);
} catch (DatabaseException e) {
Logger.defaultLogError(e);
} else {
- final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
- procedure, "request");
+// final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
+// procedure, "request");
- try {
+ BlockingAsyncProcedure<T> wrap = new BlockingAsyncProcedure<T>(procedure, request);
-// newGraph.state.barrier.inc();
-
- request.perform(newGraph, wrapper);
+ try {
-// newGraph.waitAsync(request);
+ request.perform(newGraph, wrap);
+ wrap.get();
} catch (Throwable t) {
- wrapper.exception(newGraph, t);
+ wrap.exception(newGraph, t);
+
+// wrapper.exception(newGraph, t);
// newGraph.waitAsync(request);
if (listener != null) {
- newGraph.processor.query(newGraph, request, null, new Procedure<T>() {
-
- @Override
- public void exception(Throwable t) {
- procedure.exception(t);
- if(throwable != null) {
- throwable.set(t);
- }
- }
-
- @Override
- public void execute(T t) {
- if(result != null) result.set(t);
- procedure.execute(t);
- }
-
- }, listener);
+ try {
+ QueryCacheBase.resultExternalReadEntry(newGraph, request, null, listener, procedure);
+ } catch (DatabaseException e) {
+ Logger.defaultLogError(e);
+ }
+
+
+// newGraph.processor.query(newGraph, request, null, new Procedure<T>() {
+//
+// @Override
+// public void exception(Throwable t) {
+// procedure.exception(t);
+// if(throwable != null) {
+// throwable.set(t);
+// }
+// }
+//
+// @Override
+// public void execute(T t) {
+// if(result != null) result.set(t);
+// procedure.execute(t);
+// }
+//
+// }, listener);
// newGraph.waitAsync(request);
public int getAmountOfQueryThreads() {
// This must be a power of two
- return 4;
+ return 16;
// return Integer.highestOneBit(Runtime.getRuntime().availableProcessors());
}