Refactoring that is likely to help JVM optimize QNode more aggressively
This commit is contained in:
parent
67d90615e1
commit
42afa85e53
@ -158,9 +158,14 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> implements Blocking
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean casNext(QNode cmp, QNode val) {
|
boolean casNext(QNode cmp, QNode val) {
|
||||||
if (nextUpdater == null) {
|
if (nextUpdater != null) {
|
||||||
// Safe mode.
|
return nextUpdater.compareAndSet(this, cmp, val);
|
||||||
synchronized (this) {
|
} else {
|
||||||
|
return alternativeCasNext(cmp, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized boolean alternativeCasNext(QNode cmp, QNode val) {
|
||||||
if (next == cmp) {
|
if (next == cmp) {
|
||||||
next = val;
|
next = val;
|
||||||
return true;
|
return true;
|
||||||
@ -168,10 +173,6 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> implements Blocking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return nextUpdater.compareAndSet(this, cmp, val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user