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 |
|
/** |
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 |
|
} |
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 |
|
} |
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) |
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 |
|
} |
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 |
2533 |
|
} |
2534 |
|
} |
2535 |
|
} |
2536 |
+ |
|
2537 |
|
/** |
2538 |
|
* Returns a list on non-TreeNodes replacing those in given list. |
2539 |
|
*/ |
2733 |
|
* using tree comparisons from root, but continues linear |
2734 |
|
* search when lock not available. |
2735 |
|
*/ |
2736 |
< |
final Node<K,V> find(int h, Object k) { |
2736 |
> |
final Node<K,V> find(int h, Object k) { |
2737 |
|
if (k != null) { |
2738 |
< |
for (Node<K,V> e = first; e != null; e = e.next) { |
2738 |
> |
for (Node<K,V> e = first; e != null; ) { |
2739 |
|
int s; K ek; |
2740 |
|
if (((s = lockState) & (WAITER|WRITER)) != 0) { |
2741 |
|
if (e.hash == h && |
2742 |
|
((ek = e.key) == k || (ek != null && k.equals(ek)))) |
2743 |
|
return e; |
2744 |
+ |
e = e.next; |
2745 |
|
} |
2746 |
|
else if (U.compareAndSwapInt(this, LOCKSTATE, s, |
2747 |
|
s + READER)) { |