1
16
17 package com.zaxxer.hikari.pool;
18
19 import java.util.concurrent.ScheduledExecutorService;
20
21
27 class ProxyLeakTaskFactory
28 {
29 private ScheduledExecutorService executorService;
30 private long leakDetectionThreshold;
31
32 ProxyLeakTaskFactory(final long leakDetectionThreshold, final ScheduledExecutorService executorService)
33 {
34 this.executorService = executorService;
35 this.leakDetectionThreshold = leakDetectionThreshold;
36 }
37
38 ProxyLeakTask schedule(final PoolEntry poolEntry)
39 {
40 return (leakDetectionThreshold == 0) ? ProxyLeakTask.NO_LEAK : scheduleNewTask(poolEntry);
41 }
42
43 void updateLeakDetectionThreshold(final long leakDetectionThreshold)
44 {
45 this.leakDetectionThreshold = leakDetectionThreshold;
46 }
47
48 private ProxyLeakTask scheduleNewTask(PoolEntry poolEntry) {
49 ProxyLeakTask task = new ProxyLeakTask(poolEntry);
50 task.schedule(executorService, leakDetectionThreshold);
51
52 return task;
53 }
54 }
55