Package org.postgresql.util
Class LazyCleaner
- java.lang.Object
-
- org.postgresql.util.LazyCleaner
-
public class LazyCleaner extends java.lang.Object
LazyCleaner is a utility class that allows to register objects for deferred cleanup.Note: this is a driver-internal class
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LazyCleaner.Cleanable<T extends java.lang.Throwable>
static interface
LazyCleaner.CleaningAction<T extends java.lang.Throwable>
private class
LazyCleaner.Node<T extends java.lang.Throwable>
-
Field Summary
Fields Modifier and Type Field Description private LazyCleaner.Node<?>
first
private static LazyCleaner
instance
private static java.util.logging.Logger
LOGGER
private java.lang.ref.ReferenceQueue<java.lang.Object>
queue
private java.util.concurrent.ThreadFactory
threadFactory
private boolean
threadRunning
private long
threadTtl
private int
watchedCount
-
Constructor Summary
Constructors Modifier Constructor Description LazyCleaner(java.time.Duration threadTtl, java.lang.String threadName)
private
LazyCleaner(java.time.Duration threadTtl, java.util.concurrent.ThreadFactory threadFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private <T extends java.lang.Throwable>
LazyCleaner.Node<T>add(LazyCleaner.Node<T> node)
private boolean
checkEmpty()
static LazyCleaner
getInstance()
Returns a default cleaner instance.int
getWatchedCount()
boolean
isThreadRunning()
<T extends java.lang.Throwable>
LazyCleaner.Cleanable<T>register(java.lang.Object obj, LazyCleaner.CleaningAction<T> action)
private boolean
remove(LazyCleaner.Node<?> node)
private boolean
startThread()
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
instance
private static final LazyCleaner instance
-
queue
private final java.lang.ref.ReferenceQueue<java.lang.Object> queue
-
threadTtl
private final long threadTtl
-
threadFactory
private final java.util.concurrent.ThreadFactory threadFactory
-
threadRunning
private boolean threadRunning
-
watchedCount
private int watchedCount
-
first
private LazyCleaner.Node<?> first
-
-
Method Detail
-
getInstance
public static LazyCleaner 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)
-
getWatchedCount
public int getWatchedCount()
-
isThreadRunning
public boolean isThreadRunning()
-
checkEmpty
private boolean checkEmpty()
-
add
private <T extends java.lang.Throwable> LazyCleaner.Node<T> add(LazyCleaner.Node<T> node)
-
startThread
private boolean startThread()
-
remove
private boolean remove(LazyCleaner.Node<?> node)
-
-