testLazyExecution() — netty Function Reference
Architecture documentation for the testLazyExecution() function in SingleThreadEventExecutorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a9f57147_c664_bf2e_153f_8f0cf7452606["testLazyExecution()"] bbf4ea8d_698f_542a_1559_437b1b237a04["SingleThreadEventExecutorTest"] a9f57147_c664_bf2e_153f_8f0cf7452606 -->|defined in| bbf4ea8d_698f_542a_1559_437b1b237a04 f1ac11ae_b353_9ca3_79b9_6df82a17780c["wakeup()"] a9f57147_c664_bf2e_153f_8f0cf7452606 -->|calls| f1ac11ae_b353_9ca3_79b9_6df82a17780c 73126f1a_7f15_6c07_da13_1ed18aee4cf7["LatchTask()"] a9f57147_c664_bf2e_153f_8f0cf7452606 -->|calls| 73126f1a_7f15_6c07_da13_1ed18aee4cf7 d1474077_6d3a_87c2_2d11_070af739005b["run()"] a9f57147_c664_bf2e_153f_8f0cf7452606 -->|calls| d1474077_6d3a_87c2_2d11_070af739005b style a9f57147_c664_bf2e_153f_8f0cf7452606 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java lines 415–480
@Test
public void testLazyExecution() throws Exception {
final SingleThreadEventExecutor executor = new SingleThreadEventExecutor(null,
Executors.defaultThreadFactory(), false) {
@Override
protected boolean wakesUpForTask(final Runnable task) {
return !(task instanceof LazyLatchTask);
}
@Override
protected void run() {
while (!confirmShutdown()) {
try {
synchronized (this) {
if (!hasTasks()) {
wait();
}
}
runAllTasks();
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
}
@Override
protected void wakeup(boolean inEventLoop) {
if (!inEventLoop) {
synchronized (this) {
notifyAll();
}
}
}
};
// Ensure event loop is started
LatchTask latch0 = new LatchTask();
executor.execute(latch0);
assertTrue(latch0.await(100, TimeUnit.MILLISECONDS));
// Pause to ensure it enters waiting state
Thread.sleep(100L);
// Submit task via lazyExecute
LatchTask latch1 = new LatchTask();
executor.lazyExecute(latch1);
// Sumbit lazy task via regular execute
LatchTask latch2 = new LazyLatchTask();
executor.execute(latch2);
// Neither should run yet
assertFalse(latch1.await(100, TimeUnit.MILLISECONDS));
assertFalse(latch2.await(100, TimeUnit.MILLISECONDS));
// Submit regular task via regular execute
LatchTask latch3 = new LatchTask();
executor.execute(latch3);
// Should flush latch1 and latch2 and then run latch3 immediately
assertTrue(latch3.await(100, TimeUnit.MILLISECONDS));
assertEquals(0, latch1.getCount());
assertEquals(0, latch2.getCount());
executor.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).syncUninterruptibly();
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testLazyExecution() do?
testLazyExecution() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java.
Where is testLazyExecution() defined?
testLazyExecution() is defined in common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java at line 415.
What does testLazyExecution() call?
testLazyExecution() calls 3 function(s): LatchTask, run, wakeup.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free