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

Comparing jsr166/src/extra166y/CustomConcurrentHashMap.java (file contents):
Revision 1.4 by jsr166, Wed Aug 12 04:02:45 2009 UTC vs.
Revision 1.8 by jsr166, Sun Nov 22 18:58:57 2009 UTC

# Line 533 | Line 533 | public class CustomConcurrentHashMap<K,
533              int sc = (int)((1L + (4L * es) / 3) >>> SEGMENT_BITS);
534              if (sc < MIN_SEGMENT_CAPACITY)
535                  sc = MIN_SEGMENT_CAPACITY;
536 <            else if (sc > MAX_SEGMENT_CAPACITY)
537 <                sc = MAX_SEGMENT_CAPACITY;
538 <            this.initialSegmentCapacity = sc;
536 >            int capacity = MIN_SEGMENT_CAPACITY; // ensure power of two
537 >            while (capacity < sc)
538 >                capacity <<= 1;
539 >            if (capacity > MAX_SEGMENT_CAPACITY)
540 >                capacity = MAX_SEGMENT_CAPACITY;
541 >            this.initialSegmentCapacity = capacity;
542          }
543          this.segments = (Segment[])new Segment[NSEGMENTS];
544      }
# Line 956 | Line 959 | public class CustomConcurrentHashMap<K,
959                      while (p != null) {
960                          Node n = p.getLinkage();
961                          if (p.get() != null && p.getValue() != null) {
962 +                            pred = p;
963 +                            p = n;
964 +                        }
965 +                        else {
966                              if (pred == null)
967                                  tab[i] = n;
968                              else
# Line 963 | Line 970 | public class CustomConcurrentHashMap<K,
970                              seg.decrementCount();
971                              p = n;
972                          }
966                        else {
967                            pred = p;
968                            p = n;
969                        }
973                      }
974                  }
975              } finally {
# Line 3031 | Line 3034 | public class CustomConcurrentHashMap<K,
3034      // Fenced store into segment table array. Unneeded when we have Fences
3035      static final  void storeNode(Node[] table,
3036                                   int i, Node r) {
3037 <        _unsafe.putOrderedObject(table, (i << tableShift) + tableBase, r);
3037 >        long nodeOffset = ((long) i << tableShift) + tableBase;
3038 >        _unsafe.putOrderedObject(table, nodeOffset, r);
3039      }
3040  
3041      static final  void storeSegment(Segment[] segs,
3042                                      int i, Segment s) {
3043 <        _unsafe.putOrderedObject(segs, (i << segmentsShift) + segmentsBase, s);
3043 >        long segmentOffset = ((long) i << segmentsShift) + segmentsBase;
3044 >        _unsafe.putOrderedObject(segs, segmentOffset, s);
3045      }
3046  
3047  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines