Package: org.codehaus.groovy.util

## [Java] Class ReferenceManager

- 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 and description
    `ReferenceManager(ReferenceQueue queue)` Creates a manager for the supplied queue.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `afterReferenceCreation(Reference r)` Hook invoked after a new managed reference has been created.
    `` | `public static ReferenceManager` | `createCallBackedManager(ReferenceQueue queue)` Creates a manager that removes stale entries when new references are created.
    `` | `public static ReferenceManager` | `createIdlingManager(ReferenceQueue queue)` Creates a manager that only processes queued references when asked explicitly.
    `` | `public static ReferenceManager` | `createThreadedManager(ReferenceQueue queue)` Creates a manager backed by a daemon thread that drains the supplied queue.
    `` | `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.
    `` | `public static ReferenceBundle` | `getDefaultSoftBundle()` deprecated: use ReferenceBundle.getSoftBundle
    `` | `public static ReferenceBundle` | `getDefaultWeakBundle()` deprecated: use ReferenceBundle.getWeakBundle
    `` | `protected ReferenceQueue` | `getReferenceQueue()` Returns the queue monitored by this manager.
    `` | `public void` | `removeStallEntries()` Removes any currently queued stale references.
    `` | `public void` | `stopThread()` Stops any background processing owned by this manager.
    `` | `public String` | `toString()` {@inheritDoc}

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### 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 Detail

    - #### public void afterReferenceCreation(Reference r)

      Hook invoked after a new managed reference has been created.

      Parameters:
        `r` - the created reference

    - #### 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

    - #### 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

    - #### 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

    - #### 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

    - #### @Deprecated
      public static ReferenceBundle getDefaultSoftBundle()

      deprecated:
        use ReferenceBundle.getSoftBundle

    - #### @Deprecated
      public static ReferenceBundle getDefaultWeakBundle()

      deprecated:
        use ReferenceBundle.getWeakBundle

    - #### protected ReferenceQueue getReferenceQueue()

      Returns the queue monitored by this manager.

      Returns:
        the managed reference queue, or `null`

    - #### public void removeStallEntries()

      Removes any currently queued stale references.

    - #### public void stopThread()

      Stops any background processing owned by this manager.

    - #### public String toString()

      {@inheritDoc}