Skip to content

Commit

Permalink
Reverse if order
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Sep 26, 2024
1 parent 7931ae6 commit 2cc0ffa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/org/jboss/threads/EnhancedQueueExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,17 @@ private QNode getOrAddNode(PoolThreadNode nextPoolThreadNode) {
// headNext == head can happen if another consumer has already consumed head:
// retry with a fresh head
if (headNext != head) {
if (headNext instanceof TaskNode) {
if (headNext instanceof PoolThreadNode || headNext == null) {
nextPoolThreadNode.setNextRelaxed(headNext);
if (head.compareAndSetNext(headNext, nextPoolThreadNode)) {
return nextPoolThreadNode;
} else if (headNext != null) {
// GC Nepotism:
// save dragging headNext into old generation
// (although being a PoolThreadNode it won't make a big difference)
nextPoolThreadNode.setNextRelaxed(null);
}
} else if (headNext instanceof TaskNode) {
TaskNode taskNode = (TaskNode) headNext;
if (compareAndSetHead(head, taskNode)) {
// save from GC Nepotism: generational GCs don't like
Expand All @@ -1699,16 +1709,6 @@ private QNode getOrAddNode(PoolThreadNode nextPoolThreadNode) {
if (getQueueLimited()) decreaseQueueSize();
return taskNode;
}
} else if (headNext instanceof PoolThreadNode || headNext == null) {
nextPoolThreadNode.setNextRelaxed(headNext);
if (head.compareAndSetNext(headNext, nextPoolThreadNode)) {
return nextPoolThreadNode;
} else if (headNext != null) {
// GC Nepotism:
// save dragging headNext into old generation
// (although being a PoolThreadNode it won't make a big difference)
nextPoolThreadNode.setNextRelaxed(null);
}
} else {
assert headNext instanceof TerminateWaiterNode;
return headNext;
Expand Down

0 comments on commit 2cc0ffa

Please sign in to comment.