Top Description Inners Fields Constructors Methods
io.netty.util.internal

public final Class ObjectCleaner

extends Object
Class Inheritance
Imports
io.netty.util.concurrent.FastThreadLocalThread, java.lang.ref.ReferenceQueue, .WeakReference, java.security.AccessController, .PrivilegedAction, java.util.Set, java.util.concurrent.atomic.AtomicBoolean

Allows a way to register some Runnable that will executed once there are no references to an Object anymore.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final AtomicBoolean
private static final Runnable
pack-priv static final String
private static final Set<ObjectCleaner.AutomaticCleanerReference>
private static final ReferenceQueue<Object>
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static int
public static void
register(Object object, Runnable cleanupTask)

Register the given Object for which the Runnable will be executed once there are no references to the object anymore.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLEANER_RUNNINGback to summary
private static final AtomicBoolean CLEANER_RUNNING
CLEANER_TASKback to summary
private static final Runnable CLEANER_TASK
CLEANER_THREAD_NAMEback to summary
pack-priv static final String CLEANER_THREAD_NAME
LIVE_SETback to summary
private static final Set<ObjectCleaner.AutomaticCleanerReference> LIVE_SET
REFERENCE_QUEUEback to summary
private static final ReferenceQueue<Object> REFERENCE_QUEUE
REFERENCE_QUEUE_POLL_TIMEOUT_MSback to summary
private static final int REFERENCE_QUEUE_POLL_TIMEOUT_MS

Constructor Detail

ObjectCleanerback to summary
private ObjectCleaner()

Method Detail

getLiveSetCountback to summary
public static int getLiveSetCount()
registerback to summary
public static void register(Object object, Runnable cleanupTask)

Register the given Object for which the Runnable will be executed once there are no references to the object anymore. This should only be used if there are no other ways to execute some cleanup once the Object is not reachable anymore because it is not a cheap way to handle the cleanup.

io.netty.util.internal back to summary

private final Class ObjectCleaner.AutomaticCleanerReference

extends WeakReference<Object>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Runnable

Constructor Summary

AccessConstructor and Description
pack-priv
AutomaticCleanerReference(Object referent, Runnable cleanupTask)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public void
clear()

Overrides java.lang.ref.Reference.clear.

Clears this reference object.
public Thread
get()

Overrides java.lang.ref.Reference.get.

Returns this reference object's referent.

Field Detail

cleanupTaskback to summary
private final Runnable cleanupTask

Constructor Detail

AutomaticCleanerReferenceback to summary
pack-priv AutomaticCleanerReference(Object referent, Runnable cleanupTask)

Method Detail

cleanupback to summary
pack-priv void cleanup()
clearback to summary
public void clear()

Overrides java.lang.ref.Reference.clear.

Doc from java.lang.ref.Reference.clear.

Clears this reference object. Invoking this method will not cause this object to be enqueued.

This method is invoked only by Java code; when the garbage collector clears references it does so directly, without invoking this method.

Annotations
@Override
getback to summary
public Thread get()

Overrides java.lang.ref.Reference.get.

Doc from java.lang.ref.Reference.get.

Returns this reference object's referent. If this reference object has been cleared, either by the program or by the garbage collector, then this method returns null.

Returns:Thread

The object to which this reference refers, or null if this reference object has been cleared

Annotations
@Override