ManualIoEventLoopTest Class — netty Architecture
Architecture documentation for the ManualIoEventLoopTest class in ManualIoEventLoopTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 7f1091cc_a8b6_0293_92ad_d94222ae6482["ManualIoEventLoopTest"] 00750916_11ec_74e4_0199_6353ea56d6f2["ManualIoEventLoopTest.java"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|defined in| 00750916_11ec_74e4_0199_6353ea56d6f2 a22b613f_a735_8b38_cbf9_df7cb518daa3["testRunNow()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| a22b613f_a735_8b38_cbf9_df7cb518daa3 e739f9a0_1481_b2ef_ca82_1e204cd89e8a["testRun()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| e739f9a0_1481_b2ef_ca82_1e204cd89e8a af56152a_5206_9882_68f7_6b942f0bdcb3["testShutdownOutSideOfOwningThread()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| af56152a_5206_9882_68f7_6b942f0bdcb3 7a6f419c_ba11_ae43_3231_f82972a9099d["testCallFromWrongThread()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 7a6f419c_ba11_ae43_3231_f82972a9099d 6a1bf2b3_d95f_4d17_d1e2_79c5fd93b989["testThreadEventExecutorMap()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 6a1bf2b3_d95f_4d17_d1e2_79c5fd93b989 92aa0cf7_6242_9c82_1fe1_efde7189f5ee["testInvokeAnyInEventLoop()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 92aa0cf7_6242_9c82_1fe1_efde7189f5ee d5f4b237_d3ab_bffd_c765_25e5392a2ea6["testInvokeAnyInEventLoopWithTimeout()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| d5f4b237_d3ab_bffd_c765_25e5392a2ea6 b3bf2f83_68f3_fe0d_972a_cffaa3fb0292["testInvokeAllInEventLoop()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| b3bf2f83_68f3_fe0d_972a_cffaa3fb0292 5f7a7480_bd27_aa34_919f_5bcce8ebcc58["testInvokeAllInEventLoopWithTimeout()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 5f7a7480_bd27_aa34_919f_5bcce8ebcc58 9ad20f38_37d5_14b6_eb18_e8d259bdc892["testInvokeInEventLoop()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 9ad20f38_37d5_14b6_eb18_e8d259bdc892 158dd839_f317_c7ee_51df_f48dc0c5c11f["testDelayOwningThread()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 158dd839_f317_c7ee_51df_f48dc0c5c11f 269ac8f8_2c21_0c88_7cd0_1ba80f7fda10["testRunWithoutOwner()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 269ac8f8_2c21_0c88_7cd0_1ba80f7fda10 651a02ca_880e_1f34_cb2c_7dc0f7f69236["testRunNonIoTasksSetupEventExecutor()"] 7f1091cc_a8b6_0293_92ad_d94222ae6482 -->|method| 651a02ca_880e_1f34_cb2c_7dc0f7f69236
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/ManualIoEventLoopTest.java lines 47–443
public class ManualIoEventLoopTest {
@Test
public void testRunNow() throws Exception {
Thread currentThread = Thread.currentThread();
Semaphore semaphore = new Semaphore(0);
ManualIoEventLoop eventLoop = new ManualIoEventLoop(currentThread, executor ->
new TestIoHandler(semaphore));
assertEquals(0, eventLoop.runNow());
TestRunnable runnable = new TestRunnable();
eventLoop.execute(runnable);
assertFalse(runnable.isDone());
assertEquals(1, eventLoop.runNow());
assertTrue(runnable.isDone());
eventLoop.shutdown();
while (!eventLoop.isTerminated()) {
eventLoop.runNow();
}
eventLoop.terminationFuture().sync();
}
@Test
public void testRun() throws Exception {
Thread currentThread = Thread.currentThread();
Semaphore semaphore = new Semaphore(0);
ManualIoEventLoop eventLoop = new ManualIoEventLoop(currentThread, executor ->
new TestIoHandler(semaphore));
long waitTime = TimeUnit.MILLISECONDS.toNanos(200);
long current = System.nanoTime();
assertEquals(0, eventLoop.run(waitTime));
long actualNanos = System.nanoTime() - current;
assertThat(actualNanos).isGreaterThanOrEqualTo(waitTime);
TestRunnable runnable = new TestRunnable();
eventLoop.execute(runnable);
assertFalse(runnable.isDone());
waitTime = TimeUnit.SECONDS.toNanos(1);
current = System.nanoTime();
assertEquals(1, eventLoop.run(waitTime));
assertThat(waitTime).isGreaterThan(System.nanoTime() - current);
assertTrue(runnable.isDone());
eventLoop.shutdown();
while (!eventLoop.isTerminated()) {
eventLoop.runNow();
}
eventLoop.terminationFuture().sync();
}
@Test
public void testShutdownOutSideOfOwningThread() throws Exception {
Semaphore semaphore = new Semaphore(0);
Thread ownerThread = new Thread();
ManualIoEventLoop eventLoop = new ManualIoEventLoop(ownerThread, executor ->
new TestIoHandler(semaphore));
eventLoop.shutdown();
assertTrue(eventLoop.isShuttingDown());
// we expect wakeup to be called!
assertEquals(1, semaphore.availablePermits());
}
@Test
public void testCallFromWrongThread() throws Exception {
Thread thread = new Thread();
Semaphore semaphore = new Semaphore(0);
ManualIoEventLoop eventLoop = new ManualIoEventLoop(thread, executor ->
new TestIoHandler(semaphore));
assertThrows(IllegalStateException.class, eventLoop::runNow);
assertThrows(IllegalStateException.class, () -> eventLoop.run(10));
}
@Test
public void testThreadEventExecutorMap() throws Exception {
final BlockingQueue<EventExecutor> queue = new LinkedBlockingQueue<>();
Source
Frequently Asked Questions
What is the ManualIoEventLoopTest class?
ManualIoEventLoopTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/ManualIoEventLoopTest.java.
Where is ManualIoEventLoopTest defined?
ManualIoEventLoopTest is defined in transport/src/test/java/io/netty/channel/ManualIoEventLoopTest.java at line 47.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free