X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FState.java;h=91faa719841a534ba5636a815ff1f137dc069368;hp=5adc593001cd19ae305c5fb3e00dfe181b0003e0;hb=1dd02a0d0e604a82e67f04559e213db76c9ebac5;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/State.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/State.java index 5adc59300..91faa7198 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/State.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/State.java @@ -17,6 +17,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.simantics.db.ChangeSet; +import org.simantics.db.Disposable; import org.simantics.db.Operation; import org.simantics.db.VirtualGraph; import org.simantics.db.common.utils.Logger; @@ -47,7 +48,7 @@ class State { private volatile int readCount = 0; // Must be volatile so we don't have to synchronize getReadCount. private volatile int writeCount = 0; // Must be volatile so we don't have to synchronize getWriteCount. private Thread writeOwner = null; - private int asyncCount = 1; + private volatile int asyncCount = 1; // Must be volatile so we don't have to synchronize getAsyncCount. private TransactionToken transactionToken = null; void setCombine(boolean a) { if (null != transactionToken) @@ -327,17 +328,9 @@ class State { if (vg != null && clusterStream.isDirty()) new Exception("Internal error: virtual transaction committed changes into core (" + request + ")").printStackTrace(); -// long start = System.nanoTime(); - if (null == vg) { - clusterStream.reallyFlush(); - // This was fired just before in handleUpdatesAndMetadata -// if (!writeOnly) -// session.fireMetadataListeners(graph, cs); - } else - clusterStream.clear(); - -// long duration = System.nanoTime() - start; -// System.out.println("reallyFlush " + 1e-9*duration + "s. "); + // This is needed even when the write targets a virtual graph - + // deny can always remove a persistent statement. + clusterStream.reallyFlush(); session.clientChanges = new ClientChangesImpl(session); @@ -391,6 +384,7 @@ class State { this.close(); // Everything is lost anyway. throw new IllegalStateException(e); } finally { + Disposable.safeDispose(cs); lock.unlock(); } }