|
19 | 19 | /** |
20 | 20 | * An external bridge for {@link ThreadPool} |
21 | 21 | */ |
22 | | -public class ThreadPoolBridge extends StableBridgeAPI.ProxyInternal<ThreadPool> { |
| 22 | +public interface ThreadPoolBridge extends StableBridgeAPI<ThreadPool> { |
23 | 23 |
|
24 | | - public ThreadPoolBridge(final SettingsBridge settingsBridge) { |
25 | | - this(new ThreadPool(settingsBridge.toInternal(), MeterRegistry.NOOP, new DefaultBuiltInExecutorBuilders())); |
26 | | - } |
| 24 | + long relativeTimeInMillis(); |
27 | 25 |
|
28 | | - public ThreadPoolBridge(final ThreadPool delegate) { |
29 | | - super(delegate); |
30 | | - } |
| 26 | + long absoluteTimeInMillis(); |
31 | 27 |
|
32 | | - public static boolean terminate(final ThreadPoolBridge pool, final long timeout, final TimeUnit timeUnit) { |
33 | | - return ThreadPool.terminate(pool.toInternal(), timeout, timeUnit); |
34 | | - } |
| 28 | + boolean terminate(long timeout, TimeUnit timeUnit); |
35 | 29 |
|
36 | | - public long relativeTimeInMillis() { |
37 | | - return internalDelegate.relativeTimeInMillis(); |
| 30 | + static ThreadPoolBridge create(final SettingsBridge bridgedSettings) { |
| 31 | + final ThreadPool internal = new ThreadPool(bridgedSettings.toInternal(), MeterRegistry.NOOP, new DefaultBuiltInExecutorBuilders()); |
| 32 | + return new ProxyInternal(internal); |
38 | 33 | } |
39 | 34 |
|
40 | | - public long absoluteTimeInMillis() { |
41 | | - return internalDelegate.absoluteTimeInMillis(); |
| 35 | + class ProxyInternal extends StableBridgeAPI.ProxyInternal<ThreadPool> implements ThreadPoolBridge { |
| 36 | + |
| 37 | + ProxyInternal(final ThreadPool delegate) { |
| 38 | + super(delegate); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + public long relativeTimeInMillis() { |
| 43 | + return internalDelegate.relativeTimeInMillis(); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public long absoluteTimeInMillis() { |
| 48 | + return internalDelegate.absoluteTimeInMillis(); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public boolean terminate(final long timeout, final TimeUnit timeUnit) { |
| 53 | + return ThreadPool.terminate(internalDelegate, timeout, timeUnit); |
| 54 | + } |
42 | 55 | } |
43 | 56 | } |
0 commit comments