| 270 |
} |
} |
| 271 |
|
|
| 272 |
/** |
/** |
| 273 |
* Create or reset fields of a node. Called only from transfer |
* Creates or resets fields of a node. Called only from transfer |
| 274 |
* where the node to push on stack is lazily created and |
* where the node to push on stack is lazily created and |
| 275 |
* reused when possible to help reduce intervals between reads |
* reused when possible to help reduce intervals between reads |
| 276 |
* and CASes of head and to avoid surges of garbage when CASes |
* and CASes of head and to avoid surges of garbage when CASes |
| 284 |
} |
} |
| 285 |
|
|
| 286 |
/** |
/** |
| 287 |
* Put or take an item. |
* Puts or takes an item. |
| 288 |
*/ |
*/ |
| 289 |
Object transfer(Object e, boolean timed, long nanos) { |
Object transfer(Object e, boolean timed, long nanos) { |
| 290 |
/* |
/* |
| 364 |
} |
} |
| 365 |
|
|
| 366 |
/** |
/** |
| 367 |
* Spin/block until node s is matched by a fulfill operation. |
* Spins/blocks until node s is matched by a fulfill operation. |
| 368 |
* @param s the waiting node |
* @param s the waiting node |
| 369 |
* @param timed true if timed wait |
* @param timed true if timed wait |
| 370 |
* @param nanos timeout value |
* @param nanos timeout value |
| 425 |
} |
} |
| 426 |
|
|
| 427 |
/** |
/** |
| 428 |
* Return true if node s is at head or there is an active |
* Returns true if node s is at head or there is an active |
| 429 |
* fulfiller. |
* fulfiller. |
| 430 |
*/ |
*/ |
| 431 |
boolean shouldSpin(SNode s) { |
boolean shouldSpin(SNode s) { |
| 434 |
} |
} |
| 435 |
|
|
| 436 |
/** |
/** |
| 437 |
* Unlink s from the stack |
* Unlinks s from the stack. |
| 438 |
*/ |
*/ |
| 439 |
void clean(SNode s) { |
void clean(SNode s) { |
| 440 |
s.item = null; // forget item |
s.item = null; // forget item |
| 524 |
} |
} |
| 525 |
|
|
| 526 |
/** |
/** |
| 527 |
* Return true if this node is known to be off the queue |
* Returns true if this node is known to be off the queue |
| 528 |
* because its next pointer has been forgotten due to |
* because its next pointer has been forgotten due to |
| 529 |
* an advanceHead operation. |
* an advanceHead operation. |
| 530 |
*/ |
*/ |
| 555 |
(TransferQueue.class, QNode.class, "head"); |
(TransferQueue.class, QNode.class, "head"); |
| 556 |
|
|
| 557 |
/** |
/** |
| 558 |
* Try to cas nh as new head; if successful unlink |
* Tries to cas nh as new head; if successful unlink |
| 559 |
* old head's next node to avoid garbage retention. |
* old head's next node to avoid garbage retention. |
| 560 |
*/ |
*/ |
| 561 |
void advanceHead(QNode h, QNode nh) { |
void advanceHead(QNode h, QNode nh) { |
| 568 |
(TransferQueue.class, QNode.class, "tail"); |
(TransferQueue.class, QNode.class, "tail"); |
| 569 |
|
|
| 570 |
/** |
/** |
| 571 |
* Try to cas nt as new tail. |
* Tries to cas nt as new tail. |
| 572 |
*/ |
*/ |
| 573 |
void advanceTail(QNode t, QNode nt) { |
void advanceTail(QNode t, QNode nt) { |
| 574 |
if (tail == t) |
if (tail == t) |
| 580 |
(TransferQueue.class, QNode.class, "cleanMe"); |
(TransferQueue.class, QNode.class, "cleanMe"); |
| 581 |
|
|
| 582 |
/** |
/** |
| 583 |
* Try to CAS cleanMe slot |
* Tries to CAS cleanMe slot. |
| 584 |
*/ |
*/ |
| 585 |
boolean casCleanMe(QNode cmp, QNode val) { |
boolean casCleanMe(QNode cmp, QNode val) { |
| 586 |
return (cleanMe == cmp && |
return (cleanMe == cmp && |
| 588 |
} |
} |
| 589 |
|
|
| 590 |
/** |
/** |
| 591 |
* Put or take an item. |
* Puts or takes an item. |
| 592 |
*/ |
*/ |
| 593 |
Object transfer(Object e, boolean timed, long nanos) { |
Object transfer(Object e, boolean timed, long nanos) { |
| 594 |
/* Basic algorithm is to loop trying to take either of |
/* Basic algorithm is to loop trying to take either of |
| 676 |
} |
} |
| 677 |
|
|
| 678 |
/** |
/** |
| 679 |
* Spin/block until node s is fulfilled. |
* Spins/blocks until node s is fulfilled. |
| 680 |
* @param s the waiting node |
* @param s the waiting node |
| 681 |
* @param e the comparison value for checking match |
* @param e the comparison value for checking match |
| 682 |
* @param timed true if timed wait |
* @param timed true if timed wait |
| 716 |
} |
} |
| 717 |
|
|
| 718 |
/** |
/** |
| 719 |
* Get rid of cancelled node s with original predecessor pred. |
* Gets rid of cancelled node s with original predecessor pred. |
| 720 |
*/ |
*/ |
| 721 |
void clean(QNode pred, QNode s) { |
void clean(QNode pred, QNode s) { |
| 722 |
s.waiter = null; // forget thread |
s.waiter = null; // forget thread |