Package dovetaildb.util

Examples of dovetaildb.util.MutableInt


  }
 
  static final class ReadWriteLocker {
    final TIntObjectHashMap<MutableInt> map = new TIntObjectHashMap<MutableInt>();
    public void lockForRead(int i) {
      MutableInt val;
      synchronized(map) {
        if (! map.containsKey(i)) {
          map.put(i, new MutableInt(1));
          return;
        }
        val = map.get(i);
      }
      synchronized(val)  {
        while (val.get() == -1) {
          try {
            val.wait();
          } catch (InterruptedException e) {
            throw new RuntimeException(e);
          }
        }
        val.incr();
      }
    }
View Full Code Here


        }
        val.incr();
      }
    }
    public void lockForWrite(int i) {
      MutableInt val;
      synchronized(map) {
        if (! map.containsKey(i)) {
          map.put(i, new MutableInt(-1));
          return;
        }
        val = map.get(i);
      }
      synchronized(val)  {
        while (val.get() > 0) {
          try {
            val.wait();
          } catch (InterruptedException e) {
            throw new RuntimeException(e);
          }
        }
        val.set(-1);
      }
    }
View Full Code Here

        }
        val.set(-1);
      }
    }
    public void unlock(int i) {
      MutableInt val;
      synchronized(map) {
        val = map.get(i);
      }
      synchronized(val)  {
        int curVal = val.get();
        if (curVal == -1) {
          val.set(0);
          val.notify();
        } else {
          val.decr();
          if (curVal == 1)
          val.notify();
        }
      }
    }
View Full Code Here

TOP

Related Classes of dovetaildb.util.MutableInt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.