/** * Add a new subclass to the weak set of subclasses. * * This version always constructs a new set to avoid having to synchronize * against the set when iterating it for invalidation in * invalidateCacheDescendants. * * @param subclass The subclass to add */ public synchronized void addSubclass(RubyClass subclass) { synchronized (runtime.getHierarchyLock()) { Set<RubyClass> oldSubclasses = subclasses; if (oldSubclasses == null) subclasses = oldSubclasses = new WeakHashSet<RubyClass>(4); oldSubclasses.add(subclass); } }
/** * Add a new subclass to the weak set of subclasses. * * This version always constructs a new set to avoid having to synchronize * against the set when iterating it for invalidation in * invalidateCacheDescendants. * * @param subclass The subclass to add */ public synchronized void addSubclass(RubyClass subclass) { synchronized (runtime.getHierarchyLock()) { Set<RubyClass> oldSubclasses = subclasses; if (oldSubclasses == null) subclasses = oldSubclasses = new WeakHashSet<RubyClass>(4); oldSubclasses.add(subclass); } }
@SuppressWarnings("unchecked") public void addIncludingHierarchy(IncludedModule hierarchy) { synchronized (getRuntime().getHierarchyLock()) { Set<RubyClass> including = this.includingHierarchies; if (including == Collections.EMPTY_SET) { including = this.includingHierarchies = new WeakHashSet(4); } including.add(hierarchy); } }
@SuppressWarnings("unchecked") public void addIncludingHierarchy(IncludedModule hierarchy) { synchronized (getRuntime().getHierarchyLock()) { Set<RubyClass> including = this.includingHierarchies; if (including == Collections.EMPTY_SET) { including = this.includingHierarchies = new WeakHashSet(4); } including.add(hierarchy); } }
public void addIncludingHierarchy(IncludedModuleWrapper hierarchy) { synchronized (getRuntime().getHierarchyLock()) { Set<RubyClass> oldIncludingHierarchies = includingHierarchies; if (oldIncludingHierarchies == Collections.EMPTY_SET) includingHierarchies = oldIncludingHierarchies = new WeakHashSet(4); oldIncludingHierarchies.add(hierarchy); } }
public void addIncludingHierarchy(IncludedModuleWrapper hierarchy) { synchronized (getRuntime().getHierarchyLock()) { Set<RubyClass> oldIncludingHierarchies = includingHierarchies; if (oldIncludingHierarchies == Collections.EMPTY_SET) includingHierarchies = oldIncludingHierarchies = new WeakHashSet(4); oldIncludingHierarchies.add(hierarchy); } }
@Override public WeakHashSet<T> clone() { //WeakHashSet<T> newSet = (WeakHashSet<T>) super.clone(); //newSet.map = (WeakHashMap<T, Object>) map.clone(); WeakHashSet<T> newSet = new WeakHashSet<T>(map.size()); newSet.map.putAll(this.map); return newSet; }
@Override public WeakHashSet<T> clone() { //WeakHashSet<T> newSet = (WeakHashSet<T>) super.clone(); //newSet.map = (WeakHashMap<T, Object>) map.clone(); WeakHashSet<T> newSet = new WeakHashSet<T>(map.size()); newSet.map.putAll(this.map); return newSet; }