int sz = size(); // Get current table count of active K,V pairs int newsz = sz; // First size estimate newkvs[0] = new CHM(_size); // CHM in slot 0 newkvs[1] = new int[1<<log2]; // hashes in slot 1 if( CAS_newkvs( newkvs ) ) { // NOW a resize-is-in-progress!
int sz = size(); // Get current table count of active K,V pairs int newsz = sz; // First size estimate newkvs[0] = new CHM(_size); // CHM in slot 0 newkvs[1] = new int[1<<log2]; // hashes in slot 1 if( CAS_newkvs( newkvs ) ) { // NOW a resize-is-in-progress!
int sz = size(); // Get current table count of active K,V pairs int newsz = sz; // First size estimate newkvs[0] = new CHM(_size); // CHM in slot 0 newkvs[1] = new int[1<<log2]; // hashes in slot 1 if( CAS_newkvs( newkvs ) ) { // NOW a resize-is-in-progress!
if( copy_slot(topmap,(copyidx+i)&(oldlen-1),oldkvs,newkvs) ) // Made an oldtable slot go dead? copy_check_and_promote( topmap, oldkvs, workdone );// See if we can promote copy_check_and_promote( topmap, oldkvs, 0 );// See if we can promote
if( copy_slot(topmap,(copyidx+i)&(oldlen-1),oldkvs,newkvs) ) // Made an oldtable slot go dead? copy_check_and_promote( topmap, oldkvs, workdone );// See if we can promote copy_check_and_promote( topmap, oldkvs, 0 );// See if we can promote
if( copy_slot(topmap,(copyidx+i)&(oldlen-1),oldkvs,newkvs) ) // Made an oldtable slot go dead? copy_check_and_promote( topmap, oldkvs, workdone );// See if we can promote copy_check_and_promote( topmap, oldkvs, 0 );// See if we can promote
private final void initialize( int initial_sz ) { if( initial_sz < 0 ) throw new IllegalArgumentException(); int i; // Convert to next largest power-of-2 if( initial_sz > 1024*1024 ) initial_sz = 1024*1024; for( i=MIN_SIZE_LOG; (1<<i) < (initial_sz<<2); i++ ) ; // Double size for K,V pairs, add 1 for CHM and 1 for hashes _kvs = new Object[((1<<i)<<1)+2]; _kvs[0] = new CHM(new Counter()); // CHM in slot 0 _kvs[1] = new int[1<<i]; // Matching hash entries _last_resize_milli = System.currentTimeMillis(); } // Version for subclassed readObject calls, to be called after the defaultReadObject
private final Object[] copy_slot_and_check( NonBlockingHashtable topmap, Object[] oldkvs, int idx, Object should_help ) { assert chm(oldkvs) == this; Object[] newkvs = _newkvs; // VOLATILE READ // We're only here because the caller saw a Prime, which implies a // table-copy is in progress. assert newkvs != null; if( copy_slot(topmap,idx,oldkvs,_newkvs) ) // Copy the desired slot copy_check_and_promote(topmap, oldkvs, 1); // Record the slot copied // Generically help along any copy (except if called recursively from a helper) return (should_help == null) ? newkvs : topmap.help_copy(newkvs); }
/** Returns the number of key-value mappings in this map. * @return the number of key-value mappings in this map */ @Override public int size ( ) { return chm(_kvs).size(); } /** Returns <tt>size() == 0</tt>.
private final void initialize( int initial_sz ) { if( initial_sz < 0 ) throw new IllegalArgumentException(); int i; // Convert to next largest power-of-2 if( initial_sz > 1024*1024 ) initial_sz = 1024*1024; for( i=MIN_SIZE_LOG; (1<<i) < (initial_sz<<2); i++ ) ; // Double size for K,V pairs, add 1 for CHM and 1 for hashes _kvs = new Object[((1<<i)<<1)+2]; _kvs[0] = new CHM(new Counter()); // CHM in slot 0 _kvs[1] = new int[1<<i]; // Matching hash entries _last_resize_milli = System.currentTimeMillis(); } // Version for subclassed readObject calls, to be called after the defaultReadObject
private final Object[] copy_slot_and_check( NonBlockingHashtable topmap, Object[] oldkvs, int idx, Object should_help ) { assert chm(oldkvs) == this; Object[] newkvs = _newkvs; // VOLATILE READ // We're only here because the caller saw a Prime, which implies a // table-copy is in progress. assert newkvs != null; if( copy_slot(topmap,idx,oldkvs,_newkvs) ) // Copy the desired slot copy_check_and_promote(topmap, oldkvs, 1); // Record the slot copied // Generically help along any copy (except if called recursively from a helper) return (should_help == null) ? newkvs : topmap.help_copy(newkvs); }
private final Object[] copy_slot_and_check( NonBlockingHashtable topmap, Object[] oldkvs, int idx, Object should_help ) { assert chm(oldkvs) == this; Object[] newkvs = _newkvs; // VOLATILE READ // We're only here because the caller saw a Prime, which implies a // table-copy is in progress. assert newkvs != null; if( copy_slot(topmap,idx,oldkvs,_newkvs) ) // Copy the desired slot copy_check_and_promote(topmap, oldkvs, 1); // Record the slot copied // Generically help along any copy (except if called recursively from a helper) return (should_help == null) ? newkvs : topmap.help_copy(newkvs); }
private final void initialize( int initial_sz ) { if( initial_sz < 0 ) throw new IllegalArgumentException(); int i; // Convert to next largest power-of-2 if( initial_sz > 1024*1024 ) initial_sz = 1024*1024; for( i=MIN_SIZE_LOG; (1<<i) < (initial_sz<<2); i++ ) ; // Double size for K,V pairs, add 1 for CHM and 1 for hashes _kvs = new Object[((1<<i)<<1)+2]; _kvs[0] = new CHM(new Counter()); // CHM in slot 0 _kvs[1] = new int[1<<i]; // Matching hash entries _last_resize_milli = System.currentTimeMillis(); } // Version for subclassed readObject calls, to be called after the defaultReadObject
/** Returns the number of key-value mappings in this map. * @return the number of key-value mappings in this map */ @Override public int size ( ) { return chm(_kvs).size(); } /** Returns <tt>size() == 0</tt>.
/** Returns the number of key-value mappings in this map. * @return the number of key-value mappings in this map */ @Override public int size ( ) { return chm(_kvs).size(); } /** Returns <tt>size() == 0</tt>.