From: Antti Villberg Date: Mon, 9 Jul 2018 07:10:36 +0000 (+0300) Subject: Merge branch 'private/db-threads' into private/threads-testing X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=d0e8f57df83c175bac2098412ee71646fb9ff0e9;p=simantics%2Fplatform.git Merge branch 'private/db-threads' into private/threads-testing Change-Id: I84918b6db56d8c53a8d91ed6886741009e8b7c1b --- d0e8f57df83c175bac2098412ee71646fb9ff0e9 diff --cc bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java index 9290ac99f,4e37d7fc7..d5d9445ca --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java @@@ -3507,7 -3526,7 +3526,7 @@@ public abstract class SessionImplSocke public int getAmountOfQueryThreads() { // This must be a power of two -- return 1; ++ return 8; // return Integer.highestOneBit(Runtime.getRuntime().availableProcessors()); } diff --cc bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionRequestManager.java index a29d6ce04,3209961ed..2902274b9 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionRequestManager.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionRequestManager.java @@@ -161,9 -158,19 +161,9 @@@ public class SessionRequestManager } -// public synchronized void stopRead(int thread) { -// -// try { -// transactionState.stopReadTransaction(); -// } catch (DatabaseException e) { -// e.printStackTrace(); -// } -// -// } - public synchronized void startWrite(int thread, final SessionTask task) { - session.queryProvider2.scheduleAlways(thread, new SessionTask((WriteTraits)task.object, task.thread) { + session.queryProvider2.schedule(new SessionTask(true) { @Override public void run(int thread) { diff --cc bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdaptionService2.java index 47a14ddbc,859481727..1690505a0 --- a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdaptionService2.java +++ b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdaptionService2.java @@@ -583,11 -586,16 +584,11 @@@ public class AdaptionService2 implement public T adapt(ReadGraph g, Resource r, C context, Class contextClass, Class targetClass, boolean possible) throws DatabaseException { Adapter adapter = getAdapter(g, r, context, contextClass, targetClass, possible); + if(adapter == null) return null; - SyncReadProcedure procedure = new SyncReadProcedure(); - adapter.adapt(g, r, context, procedure); - procedure.checkAndThrow(); - return procedure.result; + BlockingAsyncProcedure ap = new BlockingAsyncProcedure(g, null, adapter); - -// SyncReadProcedure procedure = new SyncReadProcedure(); + adapter.adapt(g, r, context, ap); - + return ap.get(); -// procedure.checkAndThrow(); -// return procedure.result; } diff --cc tests/org.simantics.db.tests/src/org/simantics/db/tests/api/request/misc/RequestParentTest3.java index 2bec7c21e,8181e08fb..e990a06b2 --- a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/request/misc/RequestParentTest3.java +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/request/misc/RequestParentTest3.java @@@ -33,11 -33,6 +33,11 @@@ public class RequestParentTest3 extend QueryDebug debug = session.getService(QueryDebug.class); class Request implements AsyncMultiRead { + - @Override - public int threadHash() { - return hashCode(); - } ++// @Override ++// public int threadHash() { ++// return hashCode(); ++// } @Override public void perform(AsyncReadGraph graph, AsyncMultiProcedure callback) {