Home / Function/ stop() — netty Function Reference

stop() — netty Function Reference

Architecture documentation for the stop() function in HashedWheelTimer.java from the netty codebase.

Function java CommonUtil Logging calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  bd4bf731_7996_ea82_2640_1afb233683ee["stop()"]
  0a75019c_ba28_3729_1e96_e0724c6ddc24["HashedWheelTimer"]
  bd4bf731_7996_ea82_2640_1afb233683ee -->|defined in| 0a75019c_ba28_3729_1e96_e0724c6ddc24
  ea613877_8294_fd85_27b0_0c4903842ef1["run()"]
  ea613877_8294_fd85_27b0_0c4903842ef1 -->|calls| bd4bf731_7996_ea82_2640_1afb233683ee
  931ac4e6_38e5_402d_fc9f_04aca2ea7f22["unprocessedTimeouts()"]
  bd4bf731_7996_ea82_2640_1afb233683ee -->|calls| 931ac4e6_38e5_402d_fc9f_04aca2ea7f22
  c0829aeb_3b87_2da4_8623_2515c85ff6b5["cancel()"]
  bd4bf731_7996_ea82_2640_1afb233683ee -->|calls| c0829aeb_3b87_2da4_8623_2515c85ff6b5
  style bd4bf731_7996_ea82_2640_1afb233683ee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/HashedWheelTimer.java lines 378–429

    @Override
    public Set<Timeout> stop() {
        if (Thread.currentThread() == workerThread) {
            throw new IllegalStateException(
                    HashedWheelTimer.class.getSimpleName() +
                            ".stop() cannot be called from " +
                            TimerTask.class.getSimpleName());
        }

        if (!WORKER_STATE_UPDATER.compareAndSet(this, WORKER_STATE_STARTED, WORKER_STATE_SHUTDOWN)) {
            // workerState can be 0 or 2 at this moment - let it always be 2.
            if (WORKER_STATE_UPDATER.getAndSet(this, WORKER_STATE_SHUTDOWN) != WORKER_STATE_SHUTDOWN) {
                INSTANCE_COUNTER.decrementAndGet();
                if (leak != null) {
                    boolean closed = leak.close(this);
                    assert closed;
                }
            }

            return Collections.emptySet();
        }

        try {
            boolean interrupted = false;
            while (workerThread.isAlive()) {
                workerThread.interrupt();
                try {
                    workerThread.join(100);
                } catch (InterruptedException ignored) {
                    interrupted = true;
                }
            }

            if (interrupted) {
                Thread.currentThread().interrupt();
            }
        } finally {
            INSTANCE_COUNTER.decrementAndGet();
            if (leak != null) {
                boolean closed = leak.close(this);
                assert closed;
            }
        }
        Set<Timeout> unprocessed = worker.unprocessedTimeouts();
        Set<Timeout> cancelled = new HashSet<Timeout>(unprocessed.size());
        for (Timeout timeout : unprocessed) {
            if (timeout.cancel()) {
                cancelled.add(timeout);
            }
        }
        return cancelled;
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does stop() do?
stop() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/HashedWheelTimer.java.
Where is stop() defined?
stop() is defined in common/src/main/java/io/netty/util/HashedWheelTimer.java at line 378.
What does stop() call?
stop() calls 2 function(s): cancel, unprocessedTimeouts.
What calls stop()?
stop() is called by 1 function(s): run.

Analyze Your Own Codebase

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

Try Supermodel Free