1 7 package org.jboss.cache.lock; 8 9 import java.util.concurrent.TimeUnit ; 10 import java.util.concurrent.locks.Lock ; 11 12 19 public class LockStrategyReadUncommitted implements LockStrategy 20 { 21 private SemaphoreLock wLock_; 22 private Lock rLock_; 24 public LockStrategyReadUncommitted() 25 { 26 wLock_ = new SemaphoreLock(1); 27 rLock_ = new NullLock(); 28 } 29 30 33 public Lock readLock() 34 { 35 return rLock_; 36 } 37 38 41 public Lock upgradeLockAttempt(long msecs) throws UpgradeException 42 { 43 try { 46 wLock_.tryLock(msecs, TimeUnit.MILLISECONDS); 47 } catch (InterruptedException e) { 48 throw new UpgradeException("Upgrade failed in " + msecs + " msecs", e); 49 } 50 return wLock_; 51 } 52 53 56 public Lock writeLock() 57 { 58 return wLock_; 59 } 60 } 61 | Popular Tags |