Top Description Inners Fields Constructors Methods
org.postgresql.util

public Class LazyCleaner

extends Object
Class Inheritance
Imports
org.checkerframework.checker.nullness.qual.Nullable, java.lang.ref.PhantomReference, .ReferenceQueue, java.time.Duration, java.util.concurrent.ThreadFactory, java.util.logging.Level, .Logger

LazyCleaner is a utility class that allows to register objects for deferred cleanup.

Note

this is a driver-internal class

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static interface
private class

Field Summary

Modifier and TypeField and Description
private @Nullable LazyCleaner.Node<?>
private static final LazyCleaner
private static final Logger
private final ReferenceQueue<Object>
private final ThreadFactory
private boolean
private final long
private int

Constructor Summary

AccessConstructor and Description
public
LazyCleaner(Duration threadTtl, final String threadName)

private
LazyCleaner(Duration threadTtl, ThreadFactory threadFactory)

Method Summary

Modifier and TypeMethod and Description
private synchronized <T extends Throwable> LazyCleaner.Node<T>
add(LazyCleaner.Node<T> node)

private synchronized boolean
public static LazyCleaner

Returns:

the instance of LazyCleaner
getInstance
()

Returns a default cleaner instance.

public synchronized int
public synchronized boolean
public <T extends Throwable> LazyCleaner.Cleanable<T>
private synchronized boolean
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

firstback to summary
private @Nullable LazyCleaner.Node<?> first
instanceback to summary
private static final LazyCleaner instance
LOGGERback to summary
private static final Logger LOGGER
queueback to summary
private final ReferenceQueue<Object> queue
threadFactoryback to summary
private final ThreadFactory threadFactory
threadRunningback to summary
private boolean threadRunning
threadTtlback to summary
private final long threadTtl
watchedCountback to summary
private int watchedCount

Constructor Detail

LazyCleanerback to summary
public LazyCleaner(Duration threadTtl, final String threadName)
LazyCleanerback to summary
private LazyCleaner(Duration threadTtl, ThreadFactory threadFactory)

Method Detail

addback to summary
private synchronized <T extends Throwable> LazyCleaner.Node<T> add(LazyCleaner.Node<T> node)
checkEmptyback to summary
private synchronized boolean checkEmpty()
getInstanceback to summary
public static LazyCleaner getInstance()

Returns a default cleaner instance.

Note

this is driver-internal API.

Returns:LazyCleaner

the instance of LazyCleaner

getWatchedCountback to summary
public synchronized int getWatchedCount()
isThreadRunningback to summary
public synchronized boolean isThreadRunning()
registerback to summary
public <T extends Throwable> LazyCleaner.Cleanable<T> register(Object obj, LazyCleaner.CleaningAction<T> action)
removeback to summary
private synchronized boolean remove(LazyCleaner.Node<?> node)
startThreadback to summary
private boolean startThread()
org.postgresql.util back to summary

public Interface LazyCleaner.Cleanable<T extends Throwable>

Known Direct Implementers
org.postgresql.util.LazyCleaner.Node

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

cleanback to summary
public void clean() throws Cleanable:T
org.postgresql.util back to summary

public Interface LazyCleaner.CleaningAction<T extends Throwable>

Known Direct Implementers
org.postgresql.util.LazyCleaner.Node, org.postgresql.util.SharedTimer.TimerCleanup, org.postgresql.util.TempFileHolder, org.postgresql.jdbc.PgConnectionCleaningAction

Method Summary

Modifier and TypeMethod and Description
public void
onClean(boolean leak)

Method Detail

onCleanback to summary
public void onClean(boolean leak) throws CleaningAction:T
org.postgresql.util back to summary

private Class LazyCleaner.Node<T extends Throwable>

extends PhantomReference<Object>
implements LazyCleaner.Cleanable<T extends Throwable>, LazyCleaner.CleaningAction<T extends Throwable>
Class Inheritance
All Implemented Interfaces
org.postgresql.util.LazyCleaner.CleaningAction, org.postgresql.util.LazyCleaner.Cleanable

Field Summary

Modifier and TypeField and Description
private final @Nullable LazyCleaner.CleaningAction<T>
private @Nullable LazyCleaner.Node<?>
private @Nullable LazyCleaner.Node<?>

Constructor Summary

AccessConstructor and Description
pack-priv
Node(Object referent, LazyCleaner.CleaningAction<T> action)

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.ref.PhantomReference:
get

Field Detail

actionback to summary
private final @Nullable LazyCleaner.CleaningAction<T> action
nextback to summary
private @Nullable LazyCleaner.Node<?> next

Hides java.lang.ref.Reference.next.

prevback to summary
private @Nullable LazyCleaner.Node<?> prev

Constructor Detail

Nodeback to summary
pack-priv Node(Object referent, LazyCleaner.CleaningAction<T> action)

Method Detail

cleanback to summary
public void clean() throws Node:T

Implements org.postgresql.util.LazyCleaner.Cleanable.clean.

Annotations
@Override
onCleanback to summary
public void onClean(boolean leak) throws Node:T

Implements org.postgresql.util.LazyCleaner.CleaningAction.onClean.

Annotations
@Override