Class EvictionTimer
java.lang.Object
org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.EvictionTimer
Provides a shared idle object eviction timer for all pools.
This class is currently implemented using ScheduledThreadPoolExecutor
. This implementation may change in any
future release. This class keeps track of how many pools are using it. If no pools are using the timer, it is
cancelled. This prevents a thread being left running which, in application server environments, can lead to memory
leads and/or prevent applications from shutting down or reloading cleanly.
This class has package scope to prevent its inclusion in the pool public API. The class declaration below should *not* be changed to public.
This class is intended to be thread-safe.
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Thread factory that creates a daemon thread, with the context class loader from this class. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static void
cancel
(BaseGenericObjectPool<?>.Evictor evictor, long timeout, TimeUnit unit) Removes the specified eviction task from the timer.(package private) static void
schedule
(BaseGenericObjectPool<?>.Evictor task, long delay, long period) Adds the specified eviction task to the timer.toString()
-
Field Details
-
executor
Executor instance
-
-
Constructor Details
-
EvictionTimer
private EvictionTimer()Prevents instantiation
-
-
Method Details
-
toString
-
schedule
Adds the specified eviction task to the timer. Tasks that are added with a call to this method *must* callinvalid reference
#cancel()
- Parameters:
task
- Task to be scheduled.delay
- Delay in milliseconds before task is executed.period
- Time in milliseconds between executions.
-
cancel
Removes the specified eviction task from the timer.- Parameters:
evictor
- Task to be cancelled.timeout
- If the associated executor is no longer required, how long should this thread wait for the executor to terminate?unit
- The units for the specified timeout.
-