added ability to count to Semaphore class
authoradam <adam@megacz.com>
Fri, 3 Sep 2004 00:27:30 +0000 (00:27 +0000)
committeradam <adam@megacz.com>
Fri, 3 Sep 2004 00:27:30 +0000 (00:27 +0000)
darcs-hash:20040903002730-5007d-1a8c33bb90720ccf2a955f27d432cb264fdd2273.gz

src/org/ibex/util/Semaphore.java

index ad8376f..b37993c 100644 (file)
@@ -12,9 +12,13 @@ public class Semaphore {
     
     private int val = 0;
 
+    public synchronized void dec() {
+        val--;
+    }
+    
     /** Decrement the counter, blocking if zero. */
     public synchronized void block() {
-        while(val == 0) {
+        while(val <= 0) {
             try {
                 wait();
             } catch (InterruptedException e) {