public static ReferenceManager createIdlingManager(ReferenceQueue queue) { return new ReferenceManager(queue); } public static ReferenceManager createCallBackedManager(ReferenceQueue queue) {
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); }
@Override public void removeStallEntries() { manager.removeStallEntries(); } @Override
@Override public void stopThread() { manager.stopThread(); } @Override
@Override public void afterReferenceCreation(Reference r) { if (manager==callback) { callback.afterReferenceCreation(r); return; } // we use the idle manager, so let us use the reference counter // we change the manager once the threshold is reached. There is // a small chance that the value will go beyond Integer.MAX_VALUE // so we check for values below 0 too. If threshold is low, then // this is unlikely to happen. If threshold is high, then we // have all negative values as fall back int count = refCnt.incrementAndGet(); if (count>threshold || count<0) { manager = callback; callback.afterReferenceCreation(r); } } @Override
/** * 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(); }
@Override public void afterReferenceCreation(Reference r) { if (manager==callback) { callback.afterReferenceCreation(r); return; } // we use the idle manager, so let us use the reference counter // we change the manager once the threshold is reached. There is // a small chance that the value will go beyond Integer.MAX_VALUE // so we check for values below 0 too. If threshold is low, then // this is unlikely to happen. If threshold is high, then we // have all negative values as fall back int count = refCnt.incrementAndGet(); if (count>threshold || count<0) { manager = callback; } } @Override
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 static ReferenceManager createThresholdedIdlingManager(final ReferenceQueue queue, final ReferenceManager callback, final int threshold) { if (threshold<0) throw new IllegalArgumentException("threshold must not be below 0."); return new ReferenceManager(queue){ private AtomicInteger refCnt = new AtomicInteger(); private volatile ReferenceManager manager = createIdlingManager(queue);
/** * 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(); }
public final void clear() { ref.clear(); manager.removeStallEntries(); }
@Override public void afterReferenceCreation(Reference r) { if (manager==callback) { callback.afterReferenceCreation(r); return; } // we use the idle manager, so let us use the reference counter // we change the manager once the threshold is reached. There is // a small chance that the value will go beyond Integer.MAX_VALUe // so we check for values below 0 too. If threshold is low, then // this is unlikely to happen. If threshold is high, then we // have all negative values as fall back int count = refCnt.incrementAndGet(); if (count>threshold || count<0) { manager = callback; } } @Override
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 static ReferenceManager createIdlingManager(ReferenceQueue queue) { return new ReferenceManager(queue); } public static ReferenceManager createCallBackedManager(ReferenceQueue queue) {
/** * 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(); }
public final void clear() { ref.clear(); manager.removeStallEntries(); }
@Override public void afterReferenceCreation(Reference r) { if (manager==callback) { callback.afterReferenceCreation(r); return; } // we use the idle manager, so let us use the reference counter // we change the manager once the threshold is reached. There is // a small chance that the value will go beyond Integer.MAX_VALUe // so we check for values below 0 too. If threshold is low, then // this is unlikely to happen. If threshold is high, then we // have all negative values as fall back int count = refCnt.incrementAndGet(); if (count>threshold || count<0) { manager = callback; } } @Override
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 static ReferenceManager createIdlingManager(ReferenceQueue queue) { return new ReferenceManager(queue); } public static ReferenceManager createCallBackedManager(ReferenceQueue queue) {
/** * 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(); } }