Refactoring that is likely to help JVM optimize QNode more aggressively

This commit is contained in:
Trustin Lee 2009-02-03 11:57:53 +00:00
parent 67d90615e1
commit 42afa85e53

View File

@ -158,18 +158,19 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> implements Blocking
}
boolean casNext(QNode cmp, QNode val) {
if (nextUpdater == null) {
// Safe mode.
synchronized (this) {
if (next == cmp) {
next = val;
return true;
} else {
return false;
}
}
} else {
if (nextUpdater != null) {
return nextUpdater.compareAndSet(this, cmp, val);
} else {
return alternativeCasNext(cmp, val);
}
}
private synchronized boolean alternativeCasNext(QNode cmp, QNode val) {
if (next == cmp) {
next = val;
return true;
} else {
return false;
}
}
}