int sz = size(); // Get current table count of active K,V pairs int newsz = sz; // First size estimate newchm = new CHM(_nbhml,_size,log2); if( CAS_newchm( newchm ) ) { // NOW a resize-is-in-progress!
if( copy_slot((copyidx+i)&(oldlen-1)) ) // Made an oldtable slot go dead? copy_check_and_promote( workdone );// See if we can promote copy_check_and_promote( 0 ); // See if we can promote
private void print() { for( int i=0; i<_keys.length; i++ ) { long K = _keys[i]; if( K != NO_KEY ) print_impl(i,K,_vals[i]); } CHM newchm = _newchm; // New table, if any if( newchm != null ) { System.out.println("----"); newchm.print(); } }
if( expVal == MATCH_ANY ) return null; // Will not match, even after K inserts if( CAS_key(idx, NO_KEY, key) ) { // Claim slot for Key _slots.add(1); // Raise key-slots-used count break; // Got it! final CHM newchm = resize(); if( expVal != null ) _nbhml.help_copy(); // help along an existing copy return newchm.putIfMatch(key,putval,expVal); if( (V == null && tableFull(reprobe_cnt,len)) || resize(); // Force the new table copy to start return copy_slot_and_check(idx,expVal).putIfMatch(key,putval,expVal); if( CAS_val(idx, V, putval ) ) { return copy_slot_and_check(idx,expVal).putIfMatch(key,putval,expVal);
int sz = size(); // Get current table count of active K,V pairs int newsz = sz; // First size estimate newchm = new CHM(_nbhml,_size,log2); if( CAS_newchm( newchm ) ) { // NOW a resize-is-in-progress!
CAS_key(idx, NO_KEY, (idx+_keys.length)/*a non-zero key which hashes here*/); if( CAS_val(idx,oldval,box) ) { // CAS down a box'd version of oldval _newchm.putIfMatch(key, old_unboxed, null); while( oldval != TOMBPRIME && !CAS_val(idx,oldval,TOMBPRIME) ) oldval = _vals[idx];
if( copy_slot((copyidx+i)&(oldlen-1)) ) // Made an oldtable slot go dead? copy_check_and_promote( workdone );// See if we can promote copy_check_and_promote( 0 ); // See if we can promote
return copy_slot_and_check(idx,key).get_impl(key); // Retry in the new table return _newchm == null // Table copy in progress? : copy_slot_and_check(idx,key).get_impl(key); // Retry in the new table
private void print2( ) { for( int i=0; i<_keys.length; i++ ) { long K = _keys[i]; if( K != NO_KEY ) // key is sane print2_impl(i,K,_vals[i]); } CHM newchm = _newchm; // New table, if any if( newchm != null ) { System.out.println("----"); newchm.print2(); } }
private void print() { for( int i=0; i<_keys.length; i++ ) { long K = _keys[i]; if( K != NO_KEY ) print_impl(i,K,_vals[i]); } CHM newchm = _newchm; // New table, if any if( newchm != null ) { System.out.println("----"); newchm.print(); } }
private CHM copy_slot_and_check( int idx, Object should_help ) { // We're only here because the caller saw a Prime, which implies a // table-copy is in progress. assert _newchm != null; if( copy_slot(idx) ) // Copy the desired slot copy_check_and_promote(1); // Record the slot copied // Generically help along any copy (except if called recursively from a helper) if( should_help != null ) _nbhml.help_copy(); return _newchm; }
private void initialize( final int initial_sz ) { RangeUtil.checkPositiveOrZero(initial_sz, "initial_sz"); int i; // Convert to next largest power-of-2 for( i=MIN_SIZE_LOG; (1<<i) < initial_sz; i++ ) {/*empty*/} _chm = new CHM(this,new ConcurrentAutoTable(),i); _val_1 = TOMBSTONE; // Always as-if deleted _last_resize_milli = System.currentTimeMillis(); }
/** Removes all of the mappings from this map. */ public void clear() { // Smack a new empty table down CHM newchm = new CHM(this,new ConcurrentAutoTable(),MIN_SIZE_LOG); while( !CAS(_chm_offset,_chm,newchm) ) { /*Spin until the clear works*/} CAS(_val_1_offset,_val_1,TOMBSTONE); }
if( expVal == MATCH_ANY ) return null; // Will not match, even after K inserts if( CAS_key(idx, NO_KEY, key) ) { // Claim slot for Key _slots.add(1); // Raise key-slots-used count break; // Got it! final CHM newchm = resize(); if( expVal != null ) _nbhml.help_copy(); // help along an existing copy return newchm.putIfMatch(key,putval,expVal); if( (V == null && tableFull(reprobe_cnt,len)) || resize(); // Force the new table copy to start return copy_slot_and_check(idx,expVal).putIfMatch(key,putval,expVal); if( CAS_val(idx, V, putval ) ) { return copy_slot_and_check(idx,expVal).putIfMatch(key,putval,expVal);
CAS_key(idx, NO_KEY, (idx+_keys.length)/*a non-zero key which hashes here*/); if( CAS_val(idx,oldval,box) ) { // CAS down a box'd version of oldval _newchm.putIfMatch(key, old_unboxed, null); while( oldval != TOMBPRIME && !CAS_val(idx,oldval,TOMBPRIME) ) oldval = _vals[idx];
return copy_slot_and_check(idx,key).get_impl(key); // Retry in the new table return _newchm == null // Table copy in progress? : copy_slot_and_check(idx,key).get_impl(key); // Retry in the new table
private void print2( ) { for( int i=0; i<_keys.length; i++ ) { long K = _keys[i]; if( K != NO_KEY ) // key is sane print2_impl(i,K,_vals[i]); } CHM newchm = _newchm; // New table, if any if( newchm != null ) { System.out.println("----"); newchm.print2(); } }
private void initialize( final int initial_sz ) { RangeUtil.checkPositiveOrZero(initial_sz, "initial_sz"); int i; // Convert to next largest power-of-2 for( i=MIN_SIZE_LOG; (1<<i) < initial_sz; i++ ) {/*empty*/} _chm = new CHM(this,new ConcurrentAutoTable(),i); _val_1 = TOMBSTONE; // Always as-if deleted _last_resize_milli = System.currentTimeMillis(); }
/** Removes all of the mappings from this map. */ public void clear() { // Smack a new empty table down CHM newchm = new CHM(this,new ConcurrentAutoTable(),MIN_SIZE_LOG); while( !CAS(_chm_offset,_chm,newchm) ) { /*Spin until the clear works*/} CAS(_val_1_offset,_val_1,TOMBSTONE); }
private CHM copy_slot_and_check( int idx, Object should_help ) { // We're only here because the caller saw a Prime, which implies a // table-copy is in progress. assert _newchm != null; if( copy_slot(idx) ) // Copy the desired slot copy_check_and_promote(1); // Record the slot copied // Generically help along any copy (except if called recursively from a helper) if( should_help != null ) _nbhml.help_copy(); return _newchm; }