java.lang.ref.Cleaner .
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | CleanerImpl.
A specialized implementation that tracks phantom cleanables. |
| pack-priv static class | CleanerImpl.
A PhantomCleanable implementation for tracking the Cleaner itself. |
| pack-priv static class | CleanerImpl.
A ThreadFactory for InnocuousThreads. |
| public static class | CleanerImpl.
Perform cleaning on an unreachable PhantomReference. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final CleanerImpl. | activeList
Currently active PhantomCleanable-s. |
| private static Function | cleanerImplAccess
An object to access the CleanerImpl from a Cleaner; set by Cleaner init. |
| pack-priv final ReferenceQueue |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static CleanerImpl | Returns: the corresponding CleanerImplthe cleaner cleaner)Called to get the CleanerImpl for a Cleaner. |
| public void | run()
Implements java. Process queued Cleanables as long as the cleanable lists are not empty. |
| public static void | setCleanerImplAccess(Function<Cleaner, CleanerImpl>
a function to map from Cleaner to CleanerImpl access)Called by Cleaner static initialization to provide the function to map from Cleaner to CleanerImpl. |
| public void | start(Cleaner
the cleaner cleaner, ThreadFactory the thread factory threadFactory)Starts the Cleaner implementation. |
| activeList | back to summary |
|---|---|
| pack-priv final CleanerImpl. Currently active PhantomCleanable-s. | |
| cleanerImplAccess | back to summary |
|---|---|
| private static Function<Cleaner, CleanerImpl> cleanerImplAccess An object to access the CleanerImpl from a Cleaner; set by Cleaner init. | |
| queue | back to summary |
|---|---|
| pack-priv final ReferenceQueue<Object> queue | |
| CleanerImpl | back to summary |
|---|---|
| public CleanerImpl() Constructor for CleanerImpl. | |
| getCleanerImpl | back to summary |
|---|---|
| pack-priv static CleanerImpl getCleanerImpl(Cleaner cleaner) Called to get the CleanerImpl for a Cleaner.
| |
| run | back to summary |
|---|---|
| public void run() Implements java. Process queued Cleanables as long as the cleanable lists are not empty. A Cleanable is in one of the lists for each Object and for the Cleaner itself. Terminates when the Cleaner is no longer reachable and has been cleaned and there are no more Cleanable instances for which the object is reachable. If the thread is a ManagedLocalsThread, the threadlocals are erased before each cleanup
| |
| setCleanerImplAccess | back to summary |
|---|---|
| public static void setCleanerImplAccess(Function<Cleaner, CleanerImpl> access) Called by Cleaner static initialization to provide the function to map from Cleaner to CleanerImpl.
| |
| start | back to summary |
|---|---|
| public void start(Cleaner cleaner, ThreadFactory threadFactory) Starts the Cleaner implementation. Ensure this is the CleanerImpl for the Cleaner. When started waits for Cleanables to be queued.
| |
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | CleanerImpl.
Segment node. |
| Modifier and Type | Field and Description |
|---|---|
| private CleanerImpl. | cache
Cached node instance to provide better behavior near NODE_CAPACITY threshold: if list size flips around NODE_CAPACITY, it would reuse the cached node instead of wasting and re-allocating a new node all the time. |
| private CleanerImpl. | head
Head node. |
| pack-priv static final int | NODE_CAPACITY
Capacity for a single node in the list. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | |
| public synchronized boolean | |
| public synchronized boolean | Returns: true if Cleanable was removed or false if not because it had already been removed beforeRemove this PhantomCleanable from the list. |
| pack-priv synchronized void |
| cache | back to summary |
|---|---|
| private CleanerImpl. Cached node instance to provide better behavior near NODE_CAPACITY threshold: if list size flips around NODE_CAPACITY, it would reuse the cached node instead of wasting and re-allocating a new node all the time. | |
| head | back to summary |
|---|---|
| private CleanerImpl. Head node. This is the only node where PhantomCleanables are added to or removed from. This is the only node with variable size, all other nodes linked from the head are always at full capacity. | |
| NODE_CAPACITY | back to summary |
|---|---|
| pack-priv static final int NODE_CAPACITY Capacity for a single node in the list. This balances memory overheads vs locality vs GC walking costs. | |
| CleanableList | back to summary |
|---|---|
| public CleanableList() | |
| insert | back to summary |
|---|---|
| public synchronized void insert(PhantomCleanable<?> phc) Insert this PhantomCleanable in the list. | |
| isEmpty | back to summary |
|---|---|
| public synchronized boolean isEmpty() Returns true if cleanable list is empty.
| |
| remove | back to summary |
|---|---|
| public synchronized boolean remove(PhantomCleanable<?> phc) Remove this PhantomCleanable from the list.
| |
| reset | back to summary |
|---|---|
| pack-priv synchronized void reset() Testing support: reset list to initial state. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final PhantomCleanable | |
| pack-priv CleanerImpl. | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| arr | back to summary |
|---|---|
| pack-priv final PhantomCleanable<?>[] arr | |
| next | back to summary |
|---|---|
| pack-priv CleanerImpl. | |
| size | back to summary |
|---|---|
| pack-priv int size | |
| Node | back to summary |
|---|---|
| pack-priv Node() | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | performCleanup()
Implements abstract jdk. The |
| CleanerCleanable | back to summary |
|---|---|
| pack-priv CleanerCleanable(Cleaner cleaner) | |
| performCleanup | back to summary |
|---|---|
| protected void performCleanup() Implements abstract jdk. Doc from jdk. The
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final AtomicInteger | |
| pack-priv static final ThreadFactory |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static ThreadFactory | |
| public Thread | newThread(Runnable r)
Implements java. Constructs a new unstarted |
| cleanerThreadNumber | back to summary |
|---|---|
| pack-priv final AtomicInteger cleanerThreadNumber | |
| factory | back to summary |
|---|---|
| pack-priv static final ThreadFactory factory | |
| InnocuousThreadFactory | back to summary |
|---|---|
| pack-priv InnocuousThreadFactory() | |
| factory | back to summary |
|---|---|
| pack-priv static ThreadFactory factory() | |
| newThread | back to summary |
|---|---|
| public Thread newThread(Runnable r) Implements java. Doc from java. Constructs a new unstarted | |
| Modifier and Type | Field and Description |
|---|---|
| private final Runnable |
| Access | Constructor and Description |
|---|---|
| public | PhantomCleanableRef(Object
the object to monitor obj, Cleaner the cleaner cleaner, Runnable the action Runnable action)Constructor for a phantom cleanable reference. |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides jdk. Direct clearing of the referent is not supported. |
| public Object | get()
Overrides java. Prevent access to referent even when it is still alive. |
| protected void | performCleanup()
Implements abstract jdk. The |
| action | back to summary |
|---|---|
| private final Runnable action | |
| PhantomCleanableRef | back to summary |
|---|---|
| public PhantomCleanableRef(Object obj, Cleaner cleaner, Runnable action) Constructor for a phantom cleanable reference. | |
| clear | back to summary |
|---|---|
| public void clear() Overrides jdk. Direct clearing of the referent is not supported.
| |
| get | back to summary |
|---|---|
| public Object get() Overrides java. Prevent access to referent even when it is still alive.
| |
| performCleanup | back to summary |
|---|---|
| protected void performCleanup() Implements abstract jdk. Doc from jdk. The
| |