Package org.codehaus.groovy.util

# Class ReferenceManager

java.lang.Object
org.codehaus.groovy.util.ReferenceManager

public class ReferenceManager extends Object
Coordinates cleanup of managed references using idling, callback-driven, or threaded processing.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReferenceManager(ReferenceQueue queue)`
  Creates a manager for the supplied queue.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterReferenceCreation(Reference r)`
  Hook invoked after a new managed reference has been created.
  `static ReferenceManager`
  `createCallBackedManager(ReferenceQueue queue)`
  Creates a manager that removes stale entries when new references are created.
  `static ReferenceManager`
  `createIdlingManager(ReferenceQueue queue)`
  Creates a manager that only processes queued references when asked explicitly.
  `static ReferenceManager`
  `createThreadedManager(ReferenceQueue queue)`
  Creates a manager backed by a daemon thread that drains the supplied queue.
  `static ReferenceManager`
  `createThresholdedIdlingManager(ReferenceQueue queue, ReferenceManager callback, int threshold)`
  Creates a manager that starts in idling mode and switches to the callback manager after a threshold.
  `static ReferenceBundle`
  `getDefaultSoftBundle()`
  Deprecated.
  use `ReferenceBundle.getSoftBundle()`
  `static ReferenceBundle`
  `getDefaultWeakBundle()`
  Deprecated.
  use `ReferenceBundle.getWeakBundle()`
  `protected ReferenceQueue`
  `getReferenceQueue()`
  Returns the queue monitored by this manager.
  `void`
  `removeStallEntries()`
  Removes any currently queued stale references.
  `void`
  `stopThread()`
  Stops any background processing owned by this manager.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ReferenceManager

    public ReferenceManager(ReferenceQueue queue)
    Creates a manager for the supplied queue.
    Parameters:
      `queue` - the queue containing collected references, or `null` when not queue-backed

- ## Method Details

  - ### createThreadedManager

    public static ReferenceManager createThreadedManager(ReferenceQueue queue)
    Creates a manager backed by a daemon thread that drains the supplied queue.
    Parameters:
      `queue` - the queue to drain
    Returns:
      a threaded reference manager

  - ### createIdlingManager

    public static ReferenceManager createIdlingManager(ReferenceQueue queue)
    Creates a manager that only processes queued references when asked explicitly.
    Parameters:
      `queue` - the queue to inspect
    Returns:
      an idling reference manager

  - ### createCallBackedManager

    public static ReferenceManager createCallBackedManager(ReferenceQueue queue)
    Creates a manager that removes stale entries when new references are created.
    Parameters:
      `queue` - the queue to inspect
    Returns:
      a callback-backed reference manager

  - ### createThresholdedIdlingManager

    public static ReferenceManager createThresholdedIdlingManager(ReferenceQueue queue, ReferenceManager callback, int threshold)
    Creates a manager that starts in idling mode and switches to the callback manager after a threshold.
    Parameters:
      `queue` - the queue to inspect
      `callback` - the manager to delegate to after the threshold is crossed
      `threshold` - the number of created references before switching managers
    Returns:
      a thresholded reference manager

  - ### getReferenceQueue

    protected ReferenceQueue getReferenceQueue()
    Returns the queue monitored by this manager.
    Returns:
      the managed reference queue, or `null`

  - ### afterReferenceCreation

    public void afterReferenceCreation(Reference r)
    Hook invoked after a new managed reference has been created.
    Parameters:
      `r` - the created reference

  - ### removeStallEntries

    public void removeStallEntries()
    Removes any currently queued stale references.

  - ### stopThread

    public void stopThread()
    Stops any background processing owned by this manager.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getDefaultSoftBundle

    @Deprecated public static ReferenceBundle getDefaultSoftBundle()
    Deprecated.
    use `ReferenceBundle.getSoftBundle()`

  - ### getDefaultWeakBundle

    @Deprecated public static ReferenceBundle getDefaultWeakBundle()
    Deprecated.
    use `ReferenceBundle.getWeakBundle()`