Home / Function/ confirmShutdown() — netty Function Reference

confirmShutdown() — netty Function Reference

Architecture documentation for the confirmShutdown() function in SingleThreadEventExecutor.java from the netty codebase.

Function java CommonUtil Concurrent calls 6 called by 1

Entity Profile

Dependency Diagram

graph TD
  2fbe8756_76da_a86e_960c_bf11273a6375["confirmShutdown()"]
  c9189467_acbc_07ea_3a8c_fecfe22ec122["SingleThreadEventExecutor"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|defined in| c9189467_acbc_07ea_3a8c_fecfe22ec122
  8eb7fcd3_fddd_aede_4b6c_2483c2c54021["doStartThread()"]
  8eb7fcd3_fddd_aede_4b6c_2483c2c54021 -->|calls| 2fbe8756_76da_a86e_960c_bf11273a6375
  f254ed93_aa2e_8b8e_4769_4040c5b44cf0["isShuttingDown()"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|calls| f254ed93_aa2e_8b8e_4769_4040c5b44cf0
  957fd634_92d8_ad7a_8d3f_c6d9e5d7ee2a["inEventLoop()"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|calls| 957fd634_92d8_ad7a_8d3f_c6d9e5d7ee2a
  aae2a1cf_9734_69c3_1254_17f62df7beab["runAllTasks()"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|calls| aae2a1cf_9734_69c3_1254_17f62df7beab
  da6e6a19_86d9_7143_e21b_0738d8d5c250["runShutdownHooks()"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|calls| da6e6a19_86d9_7143_e21b_0738d8d5c250
  df5ad6c1_f20a_5cc4_4ec3_0b7df5517a6c["isShutdown()"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|calls| df5ad6c1_f20a_5cc4_4ec3_0b7df5517a6c
  ced7700b_627f_0ab1_ff34_9e3824dfeea8["execute()"]
  2fbe8756_76da_a86e_960c_bf11273a6375 -->|calls| ced7700b_627f_0ab1_ff34_9e3824dfeea8
  style 2fbe8756_76da_a86e_960c_bf11273a6375 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java lines 914–967

    protected boolean confirmShutdown() {
        if (!isShuttingDown()) {
            return false;
        }

        if (!inEventLoop()) {
            throw new IllegalStateException("must be invoked from an event loop");
        }

        cancelScheduledTasks();

        if (gracefulShutdownStartTime == 0) {
            gracefulShutdownStartTime = getCurrentTimeNanos();
        }

        if (runAllTasks() || runShutdownHooks()) {
            if (isShutdown()) {
                // Executor shut down - no new tasks anymore.
                return true;
            }

            // There were tasks in the queue. Wait a little bit more until no tasks are queued for the quiet period or
            // terminate if the quiet period is 0.
            // See https://github.com/netty/netty/issues/4241
            if (gracefulShutdownQuietPeriod == 0) {
                return true;
            }
            taskQueue.offer(WAKEUP_TASK);
            return false;
        }

        final long nanoTime = getCurrentTimeNanos();

        if (isShutdown() || nanoTime - gracefulShutdownStartTime > gracefulShutdownTimeout) {
            return true;
        }

        if (nanoTime - lastExecutionTime <= gracefulShutdownQuietPeriod) {
            // Check if any tasks were added to the queue every 100ms.
            // TODO: Change the behavior of takeTask() so that it returns on timeout.
            taskQueue.offer(WAKEUP_TASK);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // Ignore
            }

            return false;
        }

        // No tasks were added for last quiet period - hopefully safe to shut down.
        // (Hopefully because we really cannot make a guarantee that there will be no execute() calls by a user.)
        return true;
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does confirmShutdown() do?
confirmShutdown() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java.
Where is confirmShutdown() defined?
confirmShutdown() is defined in common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java at line 914.
What does confirmShutdown() call?
confirmShutdown() calls 6 function(s): execute, inEventLoop, isShutdown, isShuttingDown, runAllTasks, runShutdownHooks.
What calls confirmShutdown()?
confirmShutdown() is called by 1 function(s): doStartThread.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free