Top Description Inners Fields Constructors Methods
org.xnio

public abstract Class AutomaticReference<T>

extends PhantomReference<T>
Class Inheritance
Known Direct Subclasses
org.xnio.ByteBufferSlicePool.Ref
Annotations
@Deprecated
Static Imports
java.security.AccessController.doPrivileged

Deprecated

See CleanerReference.

An automatic reference is a phantom reference which is automatically freed by a background thread when it is enqueued. Since this type of garbage collection imposes considerable overhead, it should only be used sparingly, when it is impossible to achieve correctness any other way.
Author
David M. Lloyd

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Set<AutomaticReference<?>>
pack-priv static final Object

Constructor Summary

AccessConstructor and Description
protected
AutomaticReference(final T
the object to monitor
referent
,
final Object
the permit object originally acquired from getPermit()
permit
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
private static ReferenceQueue<Object>
public final void
clear()

Overrides java.lang.ref.Reference.clear.

Not supported.

public final boolean

Returns:

nothing
enqueue
()

Overrides java.lang.ref.Reference.enqueue.

Not supported.

protected abstract void
free()

Free this reference.

public final T

Returns:

null
get
()

Overrides java.lang.ref.PhantomReference.get.

Always returns null.

public static Object

Returns:

the permit
getPermit
()

Get the security authorization permit to create automatic references.

public final boolean

Returns:

true if the reference has been enqueued, false otherwise
isEnqueued
()

Overrides java.lang.ref.Reference.isEnqueued.

Determine whether this reference has been enqueued by the garbage collector.

Field Detail

LIVE_SETback to summary
private static final Set<AutomaticReference<?>> LIVE_SET
PERMITback to summary
pack-priv static final Object PERMIT

Constructor Detail

AutomaticReferenceback to summary
protected AutomaticReference(final T referent, final Object permit)

Construct a new instance. In order to maximize performance, the only security check performed by this constructor is to verify the permit which was passed in.

Parameters
referent:T

the object to monitor

permit:Object

the permit object originally acquired from getPermit()

Method Detail

checkPermitback to summary
private static ReferenceQueue<Object> checkPermit(Object permit)
clearback to summary
public final void clear()

Overrides java.lang.ref.Reference.clear.

Not supported.

Exceptions
UnsupportedOperationException:
always
enqueueback to summary
public final boolean enqueue()

Overrides java.lang.ref.Reference.enqueue.

Not supported.

Returns:boolean

nothing

Exceptions
UnsupportedOperationException:
always
freeback to summary
protected abstract void free()

Free this reference. This method will be called from a dedicated thread or threads so this method should execute as quickly as possible.

getback to summary
public final T get()

Overrides java.lang.ref.PhantomReference.get.

Always returns null.

Returns:T

null

getPermitback to summary
public static Object getPermit()

Get the security authorization permit to create automatic references.

Returns:Object

the permit

Exceptions
SecurityException:
if a security manager is enabled and the caller does not have the createAutomaticReference RuntimePermission
isEnqueuedback to summary
public final boolean isEnqueued()

Overrides java.lang.ref.Reference.isEnqueued.

Determine whether this reference has been enqueued by the garbage collector.

Returns:boolean

true if the reference has been enqueued, false otherwise

org.xnio back to summary

pack-priv Class AutomaticReference.Cleaner

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private static final ReferenceQueue<Object>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

QUEUEback to summary
private static final ReferenceQueue<Object> QUEUE

Constructor Detail

Cleanerback to summary
pack-priv Cleaner()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.