mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor.
This commit is contained in:
@@ -657,13 +657,11 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean, Comparable<JdbcSqlSt
|
||||
// executeBatchSizeMax
|
||||
for (;;) {
|
||||
int current = executeBatchSizeMaxUpdater.get(this);
|
||||
if (current < batchSize) {
|
||||
if (executeBatchSizeMaxUpdater.compareAndSet(this, current, (int) batchSize)) {
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (current >= batchSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (executeBatchSizeMaxUpdater.compareAndSet(this, current, (int) batchSize)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -682,13 +680,11 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean, Comparable<JdbcSqlSt
|
||||
|
||||
for (;;) {
|
||||
int max = concurrentMaxUpdater.get(this);
|
||||
if (val > max) {
|
||||
if (concurrentMaxUpdater.compareAndSet(this, max, val)) {
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (val <= max) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (concurrentMaxUpdater.compareAndSet(this, max, val)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -763,16 +759,13 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean, Comparable<JdbcSqlSt
|
||||
|
||||
for (;;) {
|
||||
long current = executeSpanNanoMaxUpdater.get(this);
|
||||
if (current < nanoSpan) {
|
||||
if (executeSpanNanoMaxUpdater.compareAndSet(this, current, nanoSpan)) {
|
||||
// 可能不准确,但是绝大多数情况下都会正确,性能换取一致性
|
||||
executeNanoSpanMaxOccurTime = System.currentTimeMillis();
|
||||
if (current >= nanoSpan) {
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (executeSpanNanoMaxUpdater.compareAndSet(this, current, nanoSpan)) {
|
||||
// 可能不准确,但是绝大多数情况下都会正确,性能换取一致性
|
||||
executeNanoSpanMaxOccurTime = System.currentTimeMillis();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user