testNotEndlessExecute() — netty Function Reference
Architecture documentation for the testNotEndlessExecute() function in UnorderedThreadPoolEventExecutorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 68d15cc2_bf84_e7e4_556a_5522c2e1223a["testNotEndlessExecute()"] f0665e95_bf5c_2315_7fab_6f3711bb232f["UnorderedThreadPoolEventExecutorTest"] 68d15cc2_bf84_e7e4_556a_5522c2e1223a -->|defined in| f0665e95_bf5c_2315_7fab_6f3711bb232f style 68d15cc2_bf84_e7e4_556a_5522c2e1223a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutorTest.java lines 33–74
@Test
public void testNotEndlessExecute() throws Exception {
UnorderedThreadPoolEventExecutor executor = new UnorderedThreadPoolEventExecutor(1);
try {
// Having the first task wait on an exchanger allow us to make sure that the lister on the second task
// is not added *after* the promise completes. We need to do this to prevent a race where the second task
// and listener are completed before the DefaultPromise.NotifyListeners task get to run, which means our
// queue inspection might observe this task after the CountDownLatch opens.
final Exchanger<Void> exchanger = new Exchanger<Void>();
final CountDownLatch latch = new CountDownLatch(3);
Runnable task = new Runnable() {
@Override
public void run() {
try {
exchanger.exchange(null);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
latch.countDown();
}
};
executor.execute(task);
Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
latch.countDown();
}
}).addListener((FutureListener<Object>) f -> latch.countDown());
exchanger.exchange(null);
latch.await();
future.syncUninterruptibly();
// Now just check if the queue stays empty multiple times. This is needed as the submit to execute(...)
// by DefaultPromise may happen in an async fashion
for (int i = 0; i < 10000; i++) {
assertTrue(executor.getQueue().isEmpty());
}
} finally {
executor.shutdownGracefully();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testNotEndlessExecute() do?
testNotEndlessExecute() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutorTest.java.
Where is testNotEndlessExecute() defined?
testNotEndlessExecute() is defined in common/src/test/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutorTest.java at line 33.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free