]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionRequestManager.java
Merge "Multiple reader thread support for db client"
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / SessionRequestManager.java
index a29d6ce045bc619ceae803dfe7bf6d48cb03241a..2902274b94202c9c79610f006f5acbf91365338b 100644 (file)
@@ -118,7 +118,7 @@ public class SessionRequestManager {
        
        public synchronized void startRead(int thread, final SessionRead task) {
                
-               session.queryProvider2.scheduleAlways(thread, new SessionTask(task.object, task.thread, task.syncCaller) {
+               session.queryProvider2.schedule(new SessionTask(true) {
 
                        @Override
             public void run(int thread) {
@@ -142,7 +142,7 @@ public class SessionRequestManager {
        
        public synchronized void startReadUpdate(int thread) {
                
-               session.queryProvider2.scheduleAlways(thread, new SessionTask(null, thread) {
+               session.queryProvider2.schedule(new SessionTask(true) {
 
                        @Override
                        public void run(int thread) {
@@ -163,7 +163,7 @@ public class SessionRequestManager {
 
        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) {
@@ -184,7 +184,7 @@ public class SessionRequestManager {
 
        public synchronized void startWriteUpdate(int thread) {
                
-               session.queryProvider2.scheduleAlways(thread, new SessionTask(null, thread) {
+               session.queryProvider2.schedule(new SessionTask(true) {
 
                        @Override
                        public void run(int thread) {
@@ -216,6 +216,9 @@ public class SessionRequestManager {
                                if(!session.state.isAlive()) return;
 
                                WriteState<?> writeState = session.writeState;
+                               
+                               assert(writeState != null);
+                               
                                WriteGraphImpl graph = writeState.getGraph();
 
                                if(writeState.isExcepted()) {
@@ -268,7 +271,7 @@ public class SessionRequestManager {
                        if (!reads.isEmpty()) {
 
                                final SessionRead read = reads.poll();
-                               session.queryProvider2.scheduleAlways(thread, new SessionTask(read.object, read.thread, read.syncCaller) {
+                               session.queryProvider2.schedule(new SessionTask(true) {
 
                                        @Override
                                        public void run(int thread) {
@@ -296,7 +299,9 @@ public class SessionRequestManager {
                        
                } else {
 
-                   throw new IllegalStateException("State in ceased should be WRITE or READ or INIT (was " + state + ")"); 
+                       // Spurious wakeup
+                       
+                   //throw new IllegalStateException("State in ceased should be WRITE or READ or INIT (was " + state + ")"); 
                        
                }
                
@@ -307,7 +312,7 @@ public class SessionRequestManager {
                assert(State.INIT != state);
                
                if(State.READ == state) {
-                       session.queryProvider2.schedule(Integer.MIN_VALUE, new SessionTask(task.object, task.thread, task.syncCaller) {
+                       session.queryProvider2.schedule(new SessionTask(true) {
 
                                @Override
                                public void run(int thread) {
@@ -349,6 +354,8 @@ public class SessionRequestManager {
 
                boolean inUpdate = state == State.WRITE_UPDATE;
 
+               //System.err.println("schedule write " + task);
+               
                assert(State.INIT != state);
                //task.combine = combine != null ? combine : inUpdate;
                if(State.IDLE == state) {