[cvs] / jsr166 / src / main / java / util / concurrent / SynchronousQueue.java Repository:
ViewVC logotype

Diff of /jsr166/src/main/java/util/concurrent/SynchronousQueue.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.56, Wed Aug 3 18:57:28 2005 UTC revision 1.57, Thu Aug 18 18:34:54 2005 UTC
# Line 270  Line 270 
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
# Line 284  Line 284 
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              /*              /*
# Line 364  Line 364 
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
# Line 425  Line 425 
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) {
# Line 434  Line 434 
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
# Line 524  Line 524 
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               */               */
# Line 555  Line 555 
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) {
# Line 568  Line 568 
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)
# Line 580  Line 580 
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 &&
# Line 588  Line 588 
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
# Line 676  Line 676 
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
# Line 716  Line 716 
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

Legend:
Removed from v.1.56  
changed lines
  Added in v.1.57

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8