< prev index next >

src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java

Print this page
8211283: Miscellaneous changes imported from jsr166 CVS 2018-11
Reviewed-by: martin, chegar


2525                                     ++lc;
2526                                 }
2527                                 else {
2528                                     if ((p.prev = hiTail) == null)
2529                                         hi = p;
2530                                     else
2531                                         hiTail.next = p;
2532                                     hiTail = p;
2533                                     ++hc;
2534                                 }
2535                             }
2536                             ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :
2537                                 (hc != 0) ? new TreeBin<K,V>(lo) : t;
2538                             hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :
2539                                 (lc != 0) ? new TreeBin<K,V>(hi) : t;
2540                             setTabAt(nextTab, i, ln);
2541                             setTabAt(nextTab, i + n, hn);
2542                             setTabAt(tab, i, fwd);
2543                             advance = true;
2544                         }


2545                     }
2546                 }
2547             }
2548         }
2549     }
2550 
2551     /* ---------------- Counter support -------------- */
2552 
2553     /**
2554      * A padded cell for distributing counts.  Adapted from LongAdder
2555      * and Striped64.  See their internal docs for explanation.
2556      */
2557     @jdk.internal.vm.annotation.Contended static final class CounterCell {
2558         volatile long value;
2559         CounterCell(long x) { value = x; }
2560     }
2561 
2562     final long sumCount() {
2563         CounterCell[] cs = counterCells;
2564         long sum = baseCount;




2525                                     ++lc;
2526                                 }
2527                                 else {
2528                                     if ((p.prev = hiTail) == null)
2529                                         hi = p;
2530                                     else
2531                                         hiTail.next = p;
2532                                     hiTail = p;
2533                                     ++hc;
2534                                 }
2535                             }
2536                             ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :
2537                                 (hc != 0) ? new TreeBin<K,V>(lo) : t;
2538                             hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :
2539                                 (lc != 0) ? new TreeBin<K,V>(hi) : t;
2540                             setTabAt(nextTab, i, ln);
2541                             setTabAt(nextTab, i + n, hn);
2542                             setTabAt(tab, i, fwd);
2543                             advance = true;
2544                         }
2545                         else if (f instanceof ReservationNode)
2546                             throw new IllegalStateException("Recursive update");
2547                     }
2548                 }
2549             }
2550         }
2551     }
2552 
2553     /* ---------------- Counter support -------------- */
2554 
2555     /**
2556      * A padded cell for distributing counts.  Adapted from LongAdder
2557      * and Striped64.  See their internal docs for explanation.
2558      */
2559     @jdk.internal.vm.annotation.Contended static final class CounterCell {
2560         volatile long value;
2561         CounterCell(long x) { value = x; }
2562     }
2563 
2564     final long sumCount() {
2565         CounterCell[] cs = counterCells;
2566         long sum = baseCount;


< prev index next >