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!
private final boolean CAS_key( int idx, long old, long key ) { assert idx >= 0 && idx < _keys.length; if ( _unsafe != null ) { final int rawIndex = _Lbase + idx * _Lscale; return _unsafe.compareAndSwapLong( _keys, rawIndex, old, key ); } return CAS_keyFallback( idx, old, key ); } private final boolean CAS_keyFallback( int idx, long old, long key ) {
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
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);
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 boolean copied_into_new = (_newchm.putIfMatch(key, old_unboxed, null) == null); while( !CAS_val(idx,oldval,TOMBPRIME) ) oldval = _vals[idx];
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 boolean copied_into_new = (_newchm.putIfMatch(key, old_unboxed, null) == null); while( !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
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 final boolean CAS_val( int idx, Object old, Object val ) { assert idx >= 0 && idx < _vals.length; if ( _unsafe != null ) { final int rawIndex = _Obase + idx * _Oscale; return _unsafe.compareAndSwapObject( _vals, rawIndex, old, val ); } return CAS_valFallback( idx, old, val ); } private final boolean CAS_valFallback( int idx, Object old, Object val ) {
private final boolean CAS_val( int idx, Object old, Object val ) { assert idx >= 0 && idx < _vals.length; if ( _unsafe != null ) { final int rawIndex = _Obase + idx * _Oscale; return _unsafe.compareAndSwapObject( _vals, rawIndex, old, val ); } return CAS_valFallback( idx, old, val ); } private final boolean CAS_valFallback( int idx, Object old, Object val ) {
private final void initialize( final int initial_sz ) { if( initial_sz < 0 ) throw new IllegalArgumentException(); int i; // Convert to next largest power-of-2 for( i=MIN_SIZE_LOG; (1<<i) < initial_sz; i++ ) ; _chm = new CHM(this,new Counter(),i); _val_1 = TOMBSTONE; // Always as-if deleted _last_resize_milli = System.currentTimeMillis(); }
private final 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 final void initialize( final int initial_sz ) { if( initial_sz < 0 ) throw new IllegalArgumentException(); int i; // Convert to next largest power-of-2 for( i=MIN_SIZE_LOG; (1<<i) < initial_sz; i++ ) ; _chm = new CHM(this,new Counter(),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 Counter(),MIN_SIZE_LOG); while( !CAS_chm(_chm, newchm) ) ; // Spin until the clear works CAS_val_1(_val_1, TOMBSTONE); }
private final 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; }
/** Removes all of the mappings from this map. */ public void clear() { // Smack a new empty table down CHM newchm = new CHM(this,new Counter(),MIN_SIZE_LOG); while( !CAS_chm(_chm, newchm) ) ; // Spin until the clear works CAS_val_1(_val_1, TOMBSTONE); }
private final boolean CAS_key( int idx, long old, long key ) { assert idx >= 0 && idx < _keys.length; if ( _unsafe != null ) { final int rawIndex = _Lbase + idx * _Lscale; return _unsafe.compareAndSwapLong( _keys, rawIndex, old, key ); } return CAS_keyFallback( idx, old, key ); } private final boolean CAS_keyFallback( int idx, long old, long key ) {