ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/ConcurrentHashMapV8.java
(Generate patch)

Comparing jsr166/src/jsr166e/ConcurrentHashMapV8.java (file contents):
Revision 1.118 by dl, Sun Dec 1 16:08:12 2013 UTC vs.
Revision 1.122 by jsr166, Thu Feb 26 06:53:34 2015 UTC

# Line 15 | Line 15 | import java.lang.reflect.Type;
15   import java.util.AbstractMap;
16   import java.util.Arrays;
17   import java.util.Collection;
18 import java.util.Comparator;
18   import java.util.ConcurrentModificationException;
19   import java.util.Enumeration;
20   import java.util.HashMap;
# Line 2218 | Line 2217 | public class ConcurrentHashMapV8<K,V> ex
2217       * Must be negative when shifted left by RESIZE_STAMP_SHIFT.
2218       */
2219      static final int resizeStamp(int n) {
2220 <        return Integer.numberOfLeadingZeros(n) | (1 << (RESIZE_STAMP_BITS - 1));
2220 >        return Integer.numberOfLeadingZeros(n) | (1 << (RESIZE_STAMP_BITS - 1));
2221      }
2222  
2223      /**
# Line 2282 | Line 2281 | public class ConcurrentHashMapV8<K,V> ex
2281                  int rs = resizeStamp(n);
2282                  if (sc < 0) {
2283                      if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
2284 <                        sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
2285 <                        transferIndex <= 0)
2284 >                        sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
2285 >                        transferIndex <= 0)
2286                          break;
2287                      if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1))
2288                          transfer(tab, nt);
2289                  }
2290                  else if (U.compareAndSwapInt(this, SIZECTL, sc,
2291 <                                             (rs << RESIZE_STAMP_SHIFT) + 2))
2291 >                                             (rs << RESIZE_STAMP_SHIFT) + 2))
2292                      transfer(tab, null);
2293                  s = sumCount();
2294              }
# Line 2303 | Line 2302 | public class ConcurrentHashMapV8<K,V> ex
2302          Node<K,V>[] nextTab; int sc;
2303          if (tab != null && (f instanceof ForwardingNode) &&
2304              (nextTab = ((ForwardingNode<K,V>)f).nextTable) != null) {
2305 <            int rs = resizeStamp(tab.length);
2305 >            int rs = resizeStamp(tab.length);
2306              while (nextTab == nextTable && table == tab &&
2307 <                   (sc = sizeCtl) < 0) {
2308 <                if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
2307 >                   (sc = sizeCtl) < 0) {
2308 >                if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
2309                      sc == rs + MAX_RESIZERS || transferIndex <= 0)
2310 <                    break;
2311 <                if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) {
2310 >                    break;
2311 >                if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) {
2312                      transfer(tab, nextTab);
2313                      break;
2314                  }
# Line 2350 | Line 2349 | public class ConcurrentHashMapV8<K,V> ex
2349              else if (tab == table) {
2350                  int rs = resizeStamp(n);
2351                  if (sc < 0) {
2352 <                    Node<K,V>[] nt;
2352 >                    Node<K,V>[] nt;
2353                      if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
2354                          sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
2355                          transferIndex <= 0)
# Line 2359 | Line 2358 | public class ConcurrentHashMapV8<K,V> ex
2358                          transfer(tab, nt);
2359                  }
2360                  else if (U.compareAndSwapInt(this, SIZECTL, sc,
2361 <                                             (rs << RESIZE_STAMP_SHIFT) + 2))
2361 >                                             (rs << RESIZE_STAMP_SHIFT) + 2))
2362                      transfer(tab, null);
2363              }
2364          }
# Line 2417 | Line 2416 | public class ConcurrentHashMapV8<K,V> ex
2416                      return;
2417                  }
2418                  if (U.compareAndSwapInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {
2419 <                    if ((sc - 2) != resizeStamp(n))
2419 >                    if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT)
2420                          return;
2421                      finishing = advance = true;
2422                      i = n; // recheck before commit
# Line 2533 | Line 2532 | public class ConcurrentHashMapV8<K,V> ex
2532              }
2533          }
2534      }
2535 +
2536      /**
2537       * Returns a list on non-TreeNodes replacing those in given list.
2538       */
# Line 2578 | Line 2578 | public class ConcurrentHashMapV8<K,V> ex
2578          final TreeNode<K,V> findTreeNode(int h, Object k, Class<?> kc) {
2579              if (k != null) {
2580                  TreeNode<K,V> p = this;
2581 <                do  {
2581 >                do {
2582                      int ph, dir; K pk; TreeNode<K,V> q;
2583                      TreeNode<K,V> pl = p.left, pr = p.right;
2584                      if ((ph = p.hash) > h)
# Line 3027 | Line 3027 | public class ConcurrentHashMapV8<K,V> ex
3027  
3028          static <K,V> TreeNode<K,V> balanceDeletion(TreeNode<K,V> root,
3029                                                     TreeNode<K,V> x) {
3030 <            for (TreeNode<K,V> xp, xpl, xpr;;)  {
3030 >            for (TreeNode<K,V> xp, xpl, xpr;;) {
3031                  if (x == null || x == root)
3032                      return root;
3033                  else if ((xp = x.parent) == null) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines