public ManagedReference(ReferenceType type, ReferenceManager rmanager, T value) { if (rmanager==null) rmanager = NULL_MANAGER; this.manager = rmanager; this.ref = type.createReference(value, this, rmanager.getReferenceQueue()); rmanager.afterReferenceCreation(ref); }
public Entry<K,V> getOrPut(K key, V value) { int hash = hash(key); return segmentFor(hash).getOrPut(key, hash, value); }
/** * This method can be used to ensure that no threaded created * by a reference manager will be active. This is useful if the Groovy * runtime itself is loaded through a class loader which should be disposed * off. Without calling this method and if a threaded reference manager is * active the class loader cannot be unloaded! * * Per default no threaded manager will be used. * * @since 1.6 */ public static void stopThreadedReferenceManager() { ReferenceBundle.getSoftBundle().getManager().stopThread(); ReferenceBundle.getWeakBundle().getManager().stopThread(); }
private static void copyNonPrivateFields(SingleKeyHashMap from, SingleKeyHashMap to, CachedClass klass) { for (ComplexKeyHashMap.EntryIterator iter = from.getEntrySetIterator(); iter.hasNext();) { SingleKeyHashMap.Entry entry = (SingleKeyHashMap.Entry) iter.next(); CachedField mfp = (CachedField) entry.getValue(); if (!inheritedOrPublic(mfp) && !packageLocal(mfp, klass)) continue; to.put(entry.getKey(), mfp); } }
private void copyClassPropertyIndexForSuper(Index dest) { for (ComplexKeyHashMap.EntryIterator iter = classPropertyIndex.getEntrySetIterator(); iter.hasNext();) { SingleKeyHashMap.Entry entry = (SingleKeyHashMap.Entry) iter.next(); SingleKeyHashMap newVal = new SingleKeyHashMap(); dest.put((CachedClass) entry.getKey(), newVal); } }
public void remove(K key) { int hash = hash(key); segmentFor(hash).remove(key, hash); }
public void put(K key, V value) { int hash = hash(key); segmentFor(hash).put(key, hash, value); }
public V get(K key) { int hash = hash(key); return (V) segmentFor(hash).get(key, hash); }
@Override public void finalizeReference() { segment.removeEntry(this); super.finalizeReference(); }
public final void clear() { ref.clear(); manager.removeStallEntries(); }
public Entry putCopyOfUnexisting(Entry ee) { int h = ee.hash; final ComplexKeyHashMap.Entry[] t = table; final int index = h & (t.length - 1); Entry entry = new Entry(); entry.next = t [index]; entry.hash = h; entry.key = ee.key; entry.value = ee.value; t[index] = entry; if ( ++size == threshold ) resize(2* t.length); return entry; }
public Object copy(Object value) { if (value instanceof FastArray) return ((FastArray) value).copy(); else return value; } };
/** * adds a value to the list * * @param value the value */ public void add(T value) { Element<T> element = new Element<T>(bundle, value); element.previous = tail; if (tail != null) tail.next = element; tail = element; if (head == null) head = element; }
@Override protected <T,V extends Finalizable> Reference<T,V> createReference(T value, V handler, ReferenceQueue queue) { return new WeakRef(value, handler, queue); } },
public Object invoke(Object object, Object[] arguments) { instance2Prop.put(object, arguments[0]); return null; } }
public MetaClass getPerInstanceMetaClass(Object obj) { if (perInstanceMetaClassMap == null) return null; return perInstanceMetaClassMap.get(obj); }
/** * Gets the node meta data. * * @param key - the meta data key * @return the node meta data value for this key */ public <T> T getNodeMetaData(Object key) { if (metaDataMap == null) { return (T) null; } return (T) metaDataMap.get(key); }
void rehashIfThresholdExceeded() { if(count > threshold) { rehash(); } }
public void copyMethodsToSuper() { Entry[] table = this.table; int length = table.length; for (int j = 0; j < length; j++) { for (Entry e = table[j]; e != null; e = e.nextHashEntry) { if (e.methods instanceof FastArray) e.methodsForSuper = ((FastArray) e.methods).copy(); else e.methodsForSuper = e.methods; } } }