Home / Function/ waitForNextTick() — netty Function Reference

waitForNextTick() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  9f207468_c502_a117_0557_1b7c3aca33b8["waitForNextTick()"]
  97b31b84_3527_3690_913b_44ff6fafb9cc["Worker"]
  9f207468_c502_a117_0557_1b7c3aca33b8 -->|defined in| 97b31b84_3527_3690_913b_44ff6fafb9cc
  ea613877_8294_fd85_27b0_0c4903842ef1["run()"]
  ea613877_8294_fd85_27b0_0c4903842ef1 -->|calls| 9f207468_c502_a117_0557_1b7c3aca33b8
  style 9f207468_c502_a117_0557_1b7c3aca33b8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/HashedWheelTimer.java lines 570–605

        private long waitForNextTick() {
            long deadline = tickDuration * (tick + 1);

            for (;;) {
                final long currentTime = System.nanoTime() - startTime;
                long sleepTimeMs = (deadline - currentTime + 999999) / 1000000;

                if (sleepTimeMs <= 0) {
                    if (currentTime == Long.MIN_VALUE) {
                        return -Long.MAX_VALUE;
                    } else {
                        return currentTime;
                    }
                }

                // Check if we run on windows, as if thats the case we will need
                // to round the sleepTime as workaround for a bug that only affect
                // the JVM if it runs on windows.
                //
                // See https://github.com/netty/netty/issues/356
                if (PlatformDependent.isWindows()) {
                    sleepTimeMs = sleepTimeMs / 10 * 10;
                    if (sleepTimeMs == 0) {
                        sleepTimeMs = 1;
                    }
                }

                try {
                    Thread.sleep(sleepTimeMs);
                } catch (InterruptedException ignored) {
                    if (WORKER_STATE_UPDATER.get(HashedWheelTimer.this) == WORKER_STATE_SHUTDOWN) {
                        return Long.MIN_VALUE;
                    }
                }
            }
        }

Domain

Subdomains

Called By

Frequently Asked Questions

What does waitForNextTick() do?
waitForNextTick() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/HashedWheelTimer.java.
Where is waitForNextTick() defined?
waitForNextTick() is defined in common/src/main/java/io/netty/util/HashedWheelTimer.java at line 570.
What calls waitForNextTick()?
waitForNextTick() 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