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) (#14445) · netty/netty@9817f84

File tree

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

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

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

18+
import io.netty5.util.concurrent.AbstractEventExecutor;
1819
import io.netty5.util.concurrent.DefaultThreadFactory;
20+
import io.netty5.util.concurrent.EventExecutor;
21+
import io.netty5.util.concurrent.FastThreadLocalThread;
22+
import io.netty5.util.concurrent.Future;
1923
import io.netty5.util.internal.SystemPropertyUtil;
24+
import io.netty5.util.internal.ThreadExecutorMap;
2025
import org.openjdk.jmh.annotations.Fork;
2126
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
2227
import org.slf4j.Logger;
2328
import org.slf4j.LoggerFactory;
2429

30+
import java.util.concurrent.Callable;
2531
import java.util.concurrent.LinkedBlockingQueue;
2632
import java.util.concurrent.ThreadPoolExecutor;
2733
import java.util.concurrent.TimeUnit;
@@ -35,11 +41,78 @@ public class AbstractMicrobenchmark extends AbstractMicrobenchmarkBase {
3541
protected static final int DEFAULT_FORKS = 2;
3642

3743
public static final class HarnessExecutor extends ThreadPoolExecutor {
38-
private final Logger logger = LoggerFactory.getLogger(AbstractMicrobenchmark.class);
44+
45+
private static final Logger logger = LoggerFactory.getLogger(AbstractMicrobenchmark.class);
3946

4047
public HarnessExecutor(int maxThreads, String prefix) {
4148
super(maxThreads, maxThreads, 0, TimeUnit.MILLISECONDS,
42-
new LinkedBlockingQueue<>(), new DefaultThreadFactory(prefix));
49+
new LinkedBlockingQueue<Runnable>(),
50+
new DefaultThreadFactory(prefix));
51+
EventExecutor eventExecutor = new AbstractEventExecutor() {
52+
53+
@Override
54+
public Future<Void> schedule(Runnable task, long delay, TimeUnit unit) {
55+
throw new UnsupportedOperationException();
56+
}
57+
58+
@Override
59+
public <V> Future<V> schedule(Callable<V> task, long delay, TimeUnit unit) {
60+
throw new UnsupportedOperationException();
61+
}
62+
63+
@Override
64+
public Future<Void> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
65+
throw new UnsupportedOperationException();
66+
}
67+
68+
@Override
69+
public Future<Void> scheduleWithFixedDelay(
70+
Runnable task, long initialDelay, long delay, TimeUnit unit) {
71+
throw new UnsupportedOperationException();
72+
}
73+
74+
@Override
75+
public boolean inEventLoop(Thread thread) {
76+
return thread instanceof FastThreadLocalThread;
77+
}
78+
79+
@Override
80+
public boolean isShuttingDown() {
81+
throw new UnsupportedOperationException();
82+
}
83+
84+
@Override
85+
public Future<Void> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) {
86+
throw new UnsupportedOperationException();
87+
}
88+
89+
@Override
90+
public Future<Void> terminationFuture() {
91+
throw new UnsupportedOperationException();
92+
}
93+
94+
@Override
95+
public boolean isShutdown() {
96+
throw new UnsupportedOperationException();
97+
}
98+
99+
@Override
100+
public boolean isTerminated() {
101+
throw new UnsupportedOperationException();
102+
}
103+
104+
@Override
105+
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
106+
throw new UnsupportedOperationException();
107+
}
108+
109+
@Override
110+
public void execute(Runnable command) {
111+
throw new UnsupportedOperationException();
112+
}
113+
};
114+
setThreadFactory(ThreadExecutorMap.apply(getThreadFactory(), eventExecutor));
115+
43116
logger.debug("Using harness executor");
44117
}
45118
}

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.