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

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

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

revision 1.21, Mon Apr 5 16:05:09 2010 UTC revision 1.22, Tue Aug 17 18:31:59 2010 UTC
# Line 13  Line 13 
13  import java.util.NoSuchElementException;  import java.util.NoSuchElementException;
14  import java.util.Queue;  import java.util.Queue;
15  import java.util.concurrent.locks.LockSupport;  import java.util.concurrent.locks.LockSupport;
16    
17  /**  /**
18   * An unbounded {@link TransferQueue} based on linked nodes.   * An unbounded {@link TransferQueue} based on linked nodes.
19   * This queue orders elements FIFO (first-in-first-out) with respect   * This queue orders elements FIFO (first-in-first-out) with respect
# Line 420  Line 421 
421          }          }
422    
423          final boolean casItem(Object cmp, Object val) {          final boolean casItem(Object cmp, Object val) {
424              assert cmp == null || cmp.getClass() != Node.class;              //            assert cmp == null || cmp.getClass() != Node.class;
425              return UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val);              return UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val);
426          }          }
427    
# Line 444  Line 445 
445          /**          /**
446           * Sets item to self and waiter to null, to avoid garbage           * Sets item to self and waiter to null, to avoid garbage
447           * retention after matching or cancelling. Uses relaxed writes           * retention after matching or cancelling. Uses relaxed writes
448           * bacause order is already constrained in the only calling           * because order is already constrained in the only calling
449           * contexts: item is forgotten only after volatile/atomic           * contexts: item is forgotten only after volatile/atomic
450           * mechanics that extract items.  Similarly, clearing waiter           * mechanics that extract items.  Similarly, clearing waiter
451           * follows either CAS or return from park (if ever parked;           * follows either CAS or return from park (if ever parked;
# Line 486  Line 487 
487           * Tries to artificially match a data node -- used by remove.           * Tries to artificially match a data node -- used by remove.
488           */           */
489          final boolean tryMatchData() {          final boolean tryMatchData() {
490              assert isData;              //            assert isData;
491              Object x = item;              Object x = item;
492              if (x != null && x != this && casItem(x, null)) {              if (x != null && x != this && casItem(x, null)) {
493                  LockSupport.unpark(waiter);                  LockSupport.unpark(waiter);
# Line 539  Line 540 
540    
541      @SuppressWarnings("unchecked")      @SuppressWarnings("unchecked")
542      static <E> E cast(Object item) {      static <E> E cast(Object item) {
543          assert item == null || item.getClass() != Node.class;          //        assert item == null || item.getClass() != Node.class;
544          return (E) item;          return (E) item;
545      }      }
546    
# Line 654  Line 655 
655          for (;;) {          for (;;) {
656              Object item = s.item;              Object item = s.item;
657              if (item != e) {                  // matched              if (item != e) {                  // matched
658                  assert item != s;                  //                assert item != s;
659                  s.forgetContents();           // avoid garbage                  s.forgetContents();           // avoid garbage
660                  return this.<E>cast(item);                  return this.<E>cast(item);
661              }              }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8