improve SQL Visitor

This commit is contained in:
wenshao
2012-11-13 14:43:09 +08:00
parent 795beb3451
commit 54b83c55e9
10 changed files with 455 additions and 52 deletions
@@ -228,6 +228,8 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
protected AtomicLong createCount = new AtomicLong();
protected AtomicLong destroyCount = new AtomicLong();
private Boolean useUnfairLock = null;
public DruidAbstractDataSource(boolean lockFair){
lock = new ReentrantLock(lockFair);
@@ -246,6 +248,32 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
this.isOracle = isOracle;
}
public boolean isUseUnfairLock() {
return lock.isFair();
}
public void setUseUnfairLock(boolean useUnfairLock) {
if (lock.isFair() == !useUnfairLock) {
return;
}
if (!this.inited) {
final ReentrantLock lock = this.lock;
lock.lock();
try {
if (!this.inited) {
this.lock = new ReentrantLock(!useUnfairLock);
this.notEmpty = this.lock.newCondition();
this.empty = this.lock.newCondition();
this.useUnfairLock = useUnfairLock;
}
} finally {
lock.unlock();
}
}
}
public boolean isUseOracleImplicitCache() {
return useOracleImplicitCache;
}
@@ -794,7 +822,7 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
return;
}
if (maxWaitMillis > 0 && !this.inited) {
if (maxWaitMillis > 0 && useUnfairLock == null && !this.inited) {
final ReentrantLock lock = this.lock;
lock.lock();
try {