GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make JMH executor threads look like event loop threads (#14444) · netty/netty@6a5dd52

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • microbench/src/main/java/io/netty/microbench/util
    • AbstractMicrobenchmark.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java‎

Copy file name to clipboardExpand all lines: microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java
+61-2Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,24 @@
1515
*/
1616
package io.netty.microbench.util;
1717

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;
1822
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;
1927
import io.netty.util.internal.SystemPropertyUtil;
28+
import io.netty.util.internal.ThreadExecutorMap;
2029
import io.netty.util.internal.logging.InternalLogger;
2130
import io.netty.util.internal.logging.InternalLoggerFactory;
2231

2332
import java.util.concurrent.LinkedBlockingQueue;
2433
import java.util.concurrent.ThreadPoolExecutor;
2534
import java.util.concurrent.TimeUnit;
35+
import java.util.concurrent.TimeoutException;
2636

2737
import org.openjdk.jmh.annotations.Fork;
2838
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
@@ -36,11 +46,60 @@ public class AbstractMicrobenchmark extends AbstractMicrobenchmarkBase {
3646
protected static final int DEFAULT_FORKS = 2;
3747

3848
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);
4050

4151
public HarnessExecutor(int maxThreads, String prefix) {
4252
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+
44103
logger.debug("Using harness executor");
45104
}
46105
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.