Package org.postgresql.util
Class LazyCleanerImpl
- java.lang.Object
-
- org.postgresql.util.LazyCleanerImpl
-
- All Implemented Interfaces:
LazyCleaner
public class LazyCleanerImpl extends java.lang.Object implements LazyCleaner
LazyCleaner is a utility class that allows to register objects for deferred cleanup.This is the Java 8 compatible implementation that uses PhantomReferences and ForkJoinPool for deferred cleanup operations.
On Java 11+, this class is replaced by a version that uses the native
CleanerAPI via the multi-release JAR mechanism.Note: this is a driver-internal class
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.postgresql.util.LazyCleaner
LazyCleaner.Cleanable<T extends java.lang.Throwable>, LazyCleaner.CleaningAction<T extends java.lang.Throwable>
-
-
Constructor Summary
Constructors Constructor Description LazyCleanerImpl(java.lang.String threadName, java.time.Duration threadTtl)Creates a LazyCleaner with the specified configuration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LazyCleanerImplgetInstance()Returns a default cleaner instance.booleanisThreadRunning()Returns whether the cleanup thread is currently running.<T extends java.lang.Throwable>
LazyCleaner.Cleanable<T>register(java.lang.Object obj, LazyCleaner.CleaningAction<T> action)Registers an object for cleanup when it becomes phantom reachable.
-
-
-
Constructor Detail
-
LazyCleanerImpl
public LazyCleanerImpl(java.lang.String threadName, java.time.Duration threadTtl)Creates a LazyCleaner with the specified configuration.- Parameters:
threadName- the name for the cleanup threadthreadTtl- the maximum time the cleanup thread will wait for references
-
-
Method Detail
-
getInstance
public static LazyCleanerImpl getInstance()
Returns a default cleaner instance.Note: this is driver-internal API.
- Returns:
- the instance of LazyCleaner
-
register
public <T extends java.lang.Throwable> LazyCleaner.Cleanable<T> register(java.lang.Object obj, LazyCleaner.CleaningAction<T> action)
Description copied from interface:LazyCleanerRegisters an object for cleanup when it becomes phantom reachable.- Specified by:
registerin interfaceLazyCleaner- Type Parameters:
T- the type of exception that can be thrown during cleanup- Parameters:
obj- the object to monitor for cleanup (should not be the same as action)action- the action to perform when the object becomes unreachable- Returns:
- a Cleanable that can be used to manually trigger cleanup
-
isThreadRunning
public boolean isThreadRunning()
Returns whether the cleanup thread is currently running.- Returns:
- true if cleanup operations are active
-
-