]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/GraphSemaphore.java
Fixing URIToResource
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / GraphSemaphore.java
index 2924f0275a394cb57e160a752c8323cb3c84f03d..d5d7735aad5d3188ce75253f20eb90fdebbcce2e 100644 (file)
@@ -8,41 +8,35 @@ import org.simantics.db.exception.DatabaseException;
 
 public class GraphSemaphore extends Semaphore {
 
-       private static final long serialVersionUID = 2114861433176831938L;
-       
-       private final AsyncReadGraph graph;
-       
-       public GraphSemaphore(AsyncReadGraph graph, int permits) {
-               super(permits);
-               this.graph = graph;
-       }
-
-       public void waitFor(int permits) throws DatabaseException, InterruptedException {
-               
-       boolean success = false;
-       success = tryAcquire(permits);
-       if(success) return;
-       
-       while(!success) {
-               
-               if(graph.performPending()) {
-                       // Some task was done
-                       success = tryAcquire(permits);          
-               } else {
-                       // Nothing to do - just wait
-               try {
-                               success = tryAcquire(permits, 10, TimeUnit.SECONDS);
-                               if(!success) throw new DatabaseException("Timeout while waiting for async request to complete.");
-                       } catch (InterruptedException e) {
-                               throw new DatabaseException(e);
-                       }
-               }
-                               
-       }
-
-               
-       }
-       
-       
+    private static final long serialVersionUID = 2114861433176831938L;
 
+    private final AsyncReadGraph graph;
+
+    public GraphSemaphore(AsyncReadGraph graph, int permits) {
+        super(permits);
+        this.graph = graph;
+    }
+
+    public void waitFor(int permits) throws DatabaseException, InterruptedException {
+        boolean success = false;
+        success = tryAcquire(permits);
+        if (success)
+            return;
+
+        while (!success) {
+            if (graph.performPending()) {
+                // Some task was done
+                success = tryAcquire(permits);
+            } else {
+                // Nothing to do - just wait
+                try {
+                    success = tryAcquire(permits, 10, TimeUnit.SECONDS);
+                    if (!success)
+                        throw new DatabaseException("Timeout while waiting for async request to complete.");
+                } catch (InterruptedException e) {
+                    throw new DatabaseException(e);
+                }
+            }
+        }
+    }
 }