ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentSkipListMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentSkipListMap.java (file contents):
Revision 1.175 by jsr166, Wed Aug 16 16:45:38 2017 UTC vs.
Revision 1.176 by dl, Fri Sep 29 11:12:02 2017 UTC

# Line 295 | Line 295 | public class ConcurrentSkipListMap<K,V>
295       * Keys:         k, key
296       * Values:       v, value
297       * Comparisons:  c
298     *
299     * Note that, with VarHandles, a boolean result of
300     * compareAndSet must be declared even if not used.
298       */
299  
300      private static final long serialVersionUID = -8627078645895051609L;
# Line 398 | Line 395 | public class ConcurrentSkipListMap<K,V>
395                      break;
396                  }
397              }
398 <            boolean cas = NEXT.compareAndSet(b, n, p);
398 >            NEXT.compareAndSet(b, n, p);
399          }
400      }
401  
# Line 445 | Line 442 | public class ConcurrentSkipListMap<K,V>
442                  while ((r = q.right) != null) {
443                      Node<K,V> p; K k;
444                      if ((p = r.node) == null || (k = p.key) == null ||
445 <                        p.val == null) { // unlink index to deleted node
446 <                        boolean cas = RIGHT.compareAndSet(q, r, r.right);
450 <                    }
445 >                        p.val == null)  // unlink index to deleted node
446 >                        RIGHT.compareAndSet(q, r, r.right);
447                      else if (cpr(cmp, key, k) > 0)
448                          q = r;
449                      else
# Line 520 | Line 516 | public class ConcurrentSkipListMap<K,V>
516                  while ((r = q.right) != null) {
517                      Node<K,V> p; K k; V v; int c;
518                      if ((p = r.node) == null || (k = p.key) == null ||
519 <                        (v = p.val) == null) {
520 <                        boolean cas = RIGHT.compareAndSet(q, r, r.right);
525 <                    }
519 >                        (v = p.val) == null)
520 >                        RIGHT.compareAndSet(q, r, r.right);
521                      else if ((c = cpr(cmp, key, k)) > 0)
522                          q = r;
523                      else if (c == 0) {
# Line 586 | Line 581 | public class ConcurrentSkipListMap<K,V>
581                      while ((r = q.right) != null) {
582                          Node<K,V> p; K k;
583                          if ((p = r.node) == null || (k = p.key) == null ||
584 <                            p.val == null) {
585 <                            boolean cas = RIGHT.compareAndSet(q, r, r.right);
591 <                        }
584 >                            p.val == null)
585 >                            RIGHT.compareAndSet(q, r, r.right);
586                          else if (cpr(cmp, key, k) > 0)
587                              q = r;
588                          else
# Line 651 | Line 645 | public class ConcurrentSkipListMap<K,V>
645                              head == h) {         // try to add new level
646                              Index<K,V> hx = new Index<K,V>(z, x, null);
647                              Index<K,V> nh = new Index<K,V>(h.node, h, hx);
648 <                            boolean cas = HEAD.compareAndSet(this, h, nh);
648 >                            HEAD.compareAndSet(this, h, nh);
649                          }
650                          if (z.val == null)       // deleted while adding indices
651                              findPredecessor(key, cmp); // clean
# Line 687 | Line 681 | public class ConcurrentSkipListMap<K,V>
681                      Node<K,V> p; K k;
682                      if ((p = r.node) == null || (k = p.key) == null ||
683                          p.val == null) {
684 <                        boolean cas = RIGHT.compareAndSet(q, r, r.right);
684 >                        RIGHT.compareAndSet(q, r, r.right);
685                          c = 0;
686                      }
687                      else if ((c = cpr(cmp, key, k)) > 0)
# Line 793 | Line 787 | public class ConcurrentSkipListMap<K,V>
787              (d = h.down) != null && d.right == null &&
788              (e = d.down) != null && e.right == null &&
789              HEAD.compareAndSet(this, h, d) &&
790 <            h.right != null) {  // recheck
791 <            boolean cas = HEAD.compareAndSet(this, d, h);  // try to backout
798 <        }
790 >            h.right != null)   // recheck
791 >            HEAD.compareAndSet(this, d, h);  // try to backout
792      }
793  
794      /* ---------------- Finding and removing first element -------------- */
# Line 871 | Line 864 | public class ConcurrentSkipListMap<K,V>
864              for (Index<K,V> r, d;;) {
865                  while ((r = q.right) != null) {
866                      Node<K,V> p;
867 <                    if ((p = r.node) == null || p.val == null) {
868 <                        boolean cas = RIGHT.compareAndSet(q, r, r.right);
876 <                    }
867 >                    if ((p = r.node) == null || p.val == null)
868 >                        RIGHT.compareAndSet(q, r, r.right);
869                      else
870                          q = r;
871                  }
# Line 933 | Line 925 | public class ConcurrentSkipListMap<K,V>
925              for (;;) {
926                  Index<K,V> d, r; Node<K,V> p;
927                  while ((r = q.right) != null) {
928 <                    if ((p = r.node) == null || p.val == null) {
929 <                        boolean cas = RIGHT.compareAndSet(q, r, r.right);
938 <                    }
928 >                    if ((p = r.node) == null || p.val == null)
929 >                        RIGHT.compareAndSet(q, r, r.right);
930                      else if (p.next != null)
931                          q = r;  // continue only if a successor
932                      else
# Line 1390 | Line 1381 | public class ConcurrentSkipListMap<K,V>
1381          Index<K,V> h, r, d; Node<K,V> b;
1382          VarHandle.acquireFence();
1383          while ((h = head) != null) {
1384 <            if ((r = h.right) != null) {       // remove indices
1385 <                boolean cas = RIGHT.compareAndSet(h, r, null);
1386 <            }
1387 <            else if ((d = h.down) != null) {   // remove levels
1397 <                boolean cas = HEAD.compareAndSet(this, h, d);
1398 <            }
1384 >            if ((r = h.right) != null)        // remove indices
1385 >                RIGHT.compareAndSet(h, r, null);
1386 >            else if ((d = h.down) != null)    // remove levels
1387 >                HEAD.compareAndSet(this, h, d);
1388              else {
1389                  long count = 0L;
1390                  if ((b = h.node) != null) {    // remove nodes

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines