Package org.codehaus.groovy.util
Class ReferenceManager
java.lang.Object
org.codehaus.groovy.util.ReferenceManager
Coordinates cleanup of managed references using idling, callback-driven, or threaded processing.
-
Constructor Summary
ConstructorsConstructorDescriptionReferenceManager(ReferenceQueue queue) Creates a manager for the supplied queue. -
Method Summary
Modifier and TypeMethodDescriptionvoidHook invoked after a new managed reference has been created.static ReferenceManagerCreates a manager that removes stale entries when new references are created.static ReferenceManagerCreates a manager that only processes queued references when asked explicitly.static ReferenceManagerCreates a manager backed by a daemon thread that drains the supplied queue.static ReferenceManagercreateThresholdedIdlingManager(ReferenceQueue queue, ReferenceManager callback, int threshold) Creates a manager that starts in idling mode and switches to the callback manager after a threshold.static ReferenceBundleDeprecated.static ReferenceBundleDeprecated.protected ReferenceQueueReturns the queue monitored by this manager.voidRemoves any currently queued stale references.voidStops any background processing owned by this manager.toString()
-
Constructor Details
-
ReferenceManager
Creates a manager for the supplied queue.- Parameters:
queue- the queue containing collected references, ornullwhen not queue-backed
-
-
Method Details
-
createThreadedManager
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
Creates a manager that only processes queued references when asked explicitly.- Parameters:
queue- the queue to inspect- Returns:
- an idling reference manager
-
createCallBackedManager
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 inspectcallback- the manager to delegate to after the threshold is crossedthreshold- the number of created references before switching managers- Returns:
- a thresholded reference manager
-
getReferenceQueue
Returns the queue monitored by this manager.- Returns:
- the managed reference queue, or
null
-
afterReferenceCreation
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
-
getDefaultSoftBundle
Deprecated. -
getDefaultWeakBundle
Deprecated.
-
ReferenceBundle.getSoftBundle()