1515import static org .jctools .util .UnsafeAccess .UNSAFE ;
1616
1717import java .io .Serializable ;
18- import java .util .concurrent .atomic .AtomicReferenceFieldUpdater ;
18+ import java .util .concurrent .atomic .AtomicReferenceFieldUpdater ;
1919
2020
2121/**
@@ -49,7 +49,7 @@ public class ConcurrentAutoTable implements Serializable {
4949 /** Atomically set the sum of the striped counters to specified value.
5050 * Rather more expensive than a simple store, in order to remain atomic.
5151 */
52- public void set ( long x ) {
52+ public void set ( long x ) {
5353 CAT newcat = new CAT (null ,4 ,x );
5454 // Spin until CAS works
5555 while ( !CAS_cat (_cat ,newcat ) ) {/*empty*/ }
@@ -76,7 +76,7 @@ public void set( long x ) {
7676 * Return the counter's {@code long} value converted to a string.
7777 */
7878 public String toString () { return _cat .toString (); }
79-
79+
8080 /**
8181 * A more verbose print than {@link #toString}, showing internal structure.
8282 * Useful for debugging.
@@ -109,18 +109,18 @@ private static int hash() {
109109
110110 // --- CAT -----------------------------------------------------------------
111111 private static class CAT implements Serializable {
112-
112+
113113 // Unsafe crud: get a function which will CAS arrays
114114 private static final int _Lbase = UNSAFE .arrayBaseOffset (long [].class );
115115 private static final int _Lscale = UNSAFE .arrayIndexScale (long [].class );
116116 private static long rawIndex (long [] ary , int i ) {
117117 assert i >= 0 && i < ary .length ;
118- return _Lbase + i * _Lscale ;
118+ return _Lbase + ( i * ( long ) _Lscale ) ;
119119 }
120120 private static boolean CAS ( long [] A , int idx , long old , long nnn ) {
121121 return UNSAFE .compareAndSwapLong ( A , rawIndex (A ,idx ), old , nnn );
122122 }
123-
123+
124124 //volatile long _resizers; // count of threads attempting a resize
125125 //static private final AtomicLongFieldUpdater<CAT> _resizerUpdater =
126126 // AtomicLongFieldUpdater.newUpdater(CAT.class, "_resizers");
@@ -136,7 +136,7 @@ private static boolean CAS( long[] A, int idx, long old, long nnn ) {
136136 _t = new long [sz ];
137137 _t [0 ] = init ;
138138 }
139-
139+
140140 // Only add 'x' to some slot in table, hinted at by 'hash'. The sum can
141141 // overflow. Value is CAS'd so no counts are lost. The CAS is attempted
142142 // ONCE.
@@ -180,7 +180,7 @@ public long add_if( long x, int hash, ConcurrentAutoTable master ) {
180180 while ( master ._cat == this && !master .CAS_cat (this ,newcat ) ) {/*empty*/ }
181181 return old ;
182182 }
183-
183+
184184
185185 // Return the current sum of all things in the table. Writers can be
186186 // updating the table furiously, so the sum is only locally accurate.
@@ -206,11 +206,11 @@ public long estimate_sum( ) {
206206 }
207207
208208 public String toString ( ) { return Long .toString (sum ()); }
209-
210- public void print () {
209+
210+ public void print () {
211211 long [] t = _t ;
212212 System .out .print ("[" +t [0 ]);
213- for ( int i =1 ; i <t .length ; i ++ )
213+ for ( int i =1 ; i <t .length ; i ++ )
214214 System .out .print ("," +t [i ]);
215215 System .out .print ("]" );
216216 if ( _next != null ) _next .print ();
0 commit comments