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.121 by jsr166, Sat Dec 21 21:32:34 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines