]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/ExternalRequest.java
Fixed invalid comparisons which were identified by Eclipse IDE 2018-09
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / genericrelation / ExternalRequest.java
1 package org.simantics.db.layer0.genericrelation;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.Session;
6 import org.simantics.db.common.request.ParametrizedPrimitiveRead;
7 import org.simantics.db.layer0.adapter.GenericRelationIndex;
8 import org.simantics.db.procedure.Listener;
9 import org.simantics.utils.datastructures.Pair;
10
11 class ExternalRequest extends ParametrizedPrimitiveRead<Pair<GenericRelationIndex,Resource>,Long> implements Runnable {
12
13     private static long value = 0;
14     private Session session;
15     private Listener<Long> procedure;
16
17     public ExternalRequest(GenericRelationIndex index, Resource model) {
18         super(Pair.make(index, model));
19     }
20
21     @Override
22     public void register(ReadGraph graph, Listener<Long> procedure) {
23         synchronized(getClass()) {
24             procedure.execute(value++);
25         }
26         if(procedure.isDisposed()) return;
27         assert(this.procedure == null);
28         this.session = graph.getSession();
29         this.procedure = procedure;
30         parameter.first.addListener(graph, parameter.second, this);
31     }
32     
33     @Override
34     public void unregistered() {
35         parameter.first.removeListener(session, parameter.second, this);
36     }
37     
38     @Override
39     public void run() {
40         synchronized(getClass()) {
41             procedure.execute(value++);
42         }
43     }
44     
45 }