|
15 | 15 | */ |
16 | 16 | package io.netty.microbench.util; |
17 | 17 |
|
| 18 | +import io.netty.util.concurrent.AbstractEventExecutor; |
| 19 | +import io.netty.util.concurrent.AbstractScheduledEventExecutor; |
| 20 | +import io.netty.util.concurrent.DefaultEventExecutor; |
| 21 | +import io.netty.util.concurrent.DefaultPromise; |
18 | 22 | import io.netty.util.concurrent.DefaultThreadFactory; |
| 23 | +import io.netty.util.concurrent.EventExecutor; |
| 24 | +import io.netty.util.concurrent.FastThreadLocalThread; |
| 25 | +import io.netty.util.concurrent.Future; |
| 26 | +import io.netty.util.concurrent.SingleThreadEventExecutor; |
19 | 27 | import io.netty.util.internal.SystemPropertyUtil; |
| 28 | +import io.netty.util.internal.ThreadExecutorMap; |
20 | 29 | import io.netty.util.internal.logging.InternalLogger; |
21 | 30 | import io.netty.util.internal.logging.InternalLoggerFactory; |
22 | 31 |
|
23 | 32 | import java.util.concurrent.LinkedBlockingQueue; |
24 | 33 | import java.util.concurrent.ThreadPoolExecutor; |
25 | 34 | import java.util.concurrent.TimeUnit; |
| 35 | +import java.util.concurrent.TimeoutException; |
26 | 36 |
|
27 | 37 | import org.openjdk.jmh.annotations.Fork; |
28 | 38 | import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; |
@@ -36,11 +46,60 @@ public class AbstractMicrobenchmark extends AbstractMicrobenchmarkBase { |
36 | 46 | protected static final int DEFAULT_FORKS = 2; |
37 | 47 |
|
38 | 48 | public static final class HarnessExecutor extends ThreadPoolExecutor { |
39 | | - private final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractMicrobenchmark.class); |
| 49 | + private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractMicrobenchmark.class); |
40 | 50 |
|
41 | 51 | public HarnessExecutor(int maxThreads, String prefix) { |
42 | 52 | super(maxThreads, maxThreads, 0, TimeUnit.MILLISECONDS, |
43 | | - new LinkedBlockingQueue<Runnable>(), new DefaultThreadFactory(prefix)); |
| 53 | + new LinkedBlockingQueue<Runnable>(), |
| 54 | + new DefaultThreadFactory(prefix)); |
| 55 | + EventExecutor eventExecutor = new AbstractEventExecutor() { |
| 56 | + @Override |
| 57 | + public void shutdown() { |
| 58 | + throw new UnsupportedOperationException(); |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public boolean inEventLoop(Thread thread) { |
| 63 | + return thread instanceof FastThreadLocalThread; |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + public boolean isShuttingDown() { |
| 68 | + throw new UnsupportedOperationException(); |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { |
| 73 | + throw new UnsupportedOperationException(); |
| 74 | + } |
| 75 | + |
| 76 | + @Override |
| 77 | + public Future<?> terminationFuture() { |
| 78 | + throw new UnsupportedOperationException(); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + public boolean isShutdown() { |
| 83 | + throw new UnsupportedOperationException(); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public boolean isTerminated() { |
| 88 | + throw new UnsupportedOperationException(); |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { |
| 93 | + throw new UnsupportedOperationException(); |
| 94 | + } |
| 95 | + |
| 96 | + @Override |
| 97 | + public void execute(Runnable command) { |
| 98 | + throw new UnsupportedOperationException(); |
| 99 | + } |
| 100 | + }; |
| 101 | + setThreadFactory(ThreadExecutorMap.apply(getThreadFactory(), eventExecutor)); |
| 102 | + |
44 | 103 | logger.debug("Using harness executor"); |
45 | 104 | } |
46 | 105 | } |
|