1 package org.simantics.acorn.lru;
3 import java.util.concurrent.Semaphore;
5 import org.simantics.db.service.ClusterUID;
7 public class ClusterUpdateState {
10 final Semaphore lock = new Semaphore(0);
11 int referenceCount = 0;
12 boolean inUpdate = false;
14 ClusterUpdateState(ClusterUID uid) {
18 public void waitForUpdates() {
21 } catch (InterruptedException e) {
26 public synchronized void beginUpdate() {
27 // System.err.println("ClusterUpdateState.beginUpdate() for " + uid + ", inUpdate=" + inUpdate);
32 public synchronized void endUpdate() {
33 // System.err.println("ClusterUpdateState.endUpdate() for " + uid + ", inUpdate=" + inUpdate);
38 public synchronized void incRef() {
42 public synchronized ClusterUpdateState decRef() {
44 if(referenceCount == 0) {
45 lock.release(Integer.MAX_VALUE);