testNotSuspendedUntilScheduledTaskIsCancelled() — netty Function Reference
Architecture documentation for the testNotSuspendedUntilScheduledTaskIsCancelled() function in SingleThreadEventExecutorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 628c3ed1_70af_f127_38c3_4dcd0512b255["testNotSuspendedUntilScheduledTaskIsCancelled()"] bbf4ea8d_698f_542a_1559_437b1b237a04["SingleThreadEventExecutorTest"] 628c3ed1_70af_f127_38c3_4dcd0512b255 -->|defined in| bbf4ea8d_698f_542a_1559_437b1b237a04 28e9ff91_b16f_87e3_9960_0088813993be["SuspendingSingleThreadEventExecutor()"] 628c3ed1_70af_f127_38c3_4dcd0512b255 -->|calls| 28e9ff91_b16f_87e3_9960_0088813993be 11b0d45f_e1b4_6dba_6d37_6c2f82f7e5c1["awaitStarted()"] 628c3ed1_70af_f127_38c3_4dcd0512b255 -->|calls| 11b0d45f_e1b4_6dba_6d37_6c2f82f7e5c1 17ece757_7f91_5c24_4f58_cd664388b701["awaitRunnableExecution()"] 628c3ed1_70af_f127_38c3_4dcd0512b255 -->|calls| 17ece757_7f91_5c24_4f58_cd664388b701 style 628c3ed1_70af_f127_38c3_4dcd0512b255 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java lines 171–208
@Test
@Timeout(value = 10, unit = TimeUnit.SECONDS)
void testNotSuspendedUntilScheduledTaskIsCancelled() throws Exception {
TestThreadFactory threadFactory = new TestThreadFactory();
final SingleThreadEventExecutor executor = new SuspendingSingleThreadEventExecutor(threadFactory);
// Schedule a task which is so far in the future that we are sure it will not run at all.
Future<?> future = executor.schedule(() -> { }, 1, TimeUnit.DAYS);
TestThread currentThread = threadFactory.threads.take();
// Let's wait until the thread is started
currentThread.awaitStarted();
currentThread.awaitRunnableExecution();
assertTrue(executor.trySuspend());
// Now cancel the task which should allow the suspension to let the thread die once we call trySuspend() again
assertTrue(future.cancel(false));
future.await();
// Call in a loop as removal of scheduled tasks from task queue might be lazy
while (!executor.trySuspend()) {
Thread.sleep(50);
}
currentThread.join();
// Should be suspended now, we should be able to also call trySuspend() again.
assertTrue(executor.trySuspend());
assertTrue(executor.isSuspended());
executor.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).syncUninterruptibly();
assertFalse(executor.isSuspended());
assertTrue(executor.isShutdown());
// Guarantee that al tasks were able to die...
while ((currentThread = threadFactory.threads.poll()) != null) {
currentThread.join();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testNotSuspendedUntilScheduledTaskIsCancelled() do?
testNotSuspendedUntilScheduledTaskIsCancelled() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java.
Where is testNotSuspendedUntilScheduledTaskIsCancelled() defined?
testNotSuspendedUntilScheduledTaskIsCancelled() is defined in common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java at line 171.
What does testNotSuspendedUntilScheduledTaskIsCancelled() call?
testNotSuspendedUntilScheduledTaskIsCancelled() calls 3 function(s): SuspendingSingleThreadEventExecutor, awaitRunnableExecution, awaitStarted.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free