mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve SQL Visitor
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user