Home / Function/ await0() — netty Function Reference

await0() — netty Function Reference

Architecture documentation for the await0() function in DefaultPromise.java from the netty codebase.

Function java CommonUtil Concurrent calls 4 called by 2

Entity Profile

Dependency Diagram

graph TD
  93f49b0e_0a57_4979_d91e_7cad339bdb09["await0()"]
  a0080a71_f091_42e0_8a20_424f0bf9d34a["DefaultPromise"]
  93f49b0e_0a57_4979_d91e_7cad339bdb09 -->|defined in| a0080a71_f091_42e0_8a20_424f0bf9d34a
  a8fc55bf_4c0d_3fde_79cd_c3f808accded["await()"]
  a8fc55bf_4c0d_3fde_79cd_c3f808accded -->|calls| 93f49b0e_0a57_4979_d91e_7cad339bdb09
  468882d3_22d8_7166_9c69_b2be03be150b["awaitUninterruptibly()"]
  468882d3_22d8_7166_9c69_b2be03be150b -->|calls| 93f49b0e_0a57_4979_d91e_7cad339bdb09
  3740273d_6083_b014_4154_fce4202c359c["isDone()"]
  93f49b0e_0a57_4979_d91e_7cad339bdb09 -->|calls| 3740273d_6083_b014_4154_fce4202c359c
  60509b5d_40ce_2ffb_3446_bc55883f645e["checkDeadLock()"]
  93f49b0e_0a57_4979_d91e_7cad339bdb09 -->|calls| 60509b5d_40ce_2ffb_3446_bc55883f645e
  840a82ca_e064_c245_c313_71d5cad7b138["incWaiters()"]
  93f49b0e_0a57_4979_d91e_7cad339bdb09 -->|calls| 840a82ca_e064_c245_c313_71d5cad7b138
  eeeb5e2c_469b_65b8_2532_243d417749c2["decWaiters()"]
  93f49b0e_0a57_4979_d91e_7cad339bdb09 -->|calls| eeeb5e2c_469b_65b8_2532_243d417749c2
  style 93f49b0e_0a57_4979_d91e_7cad339bdb09 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/concurrent/DefaultPromise.java lines 691–741

    private boolean await0(long timeoutNanos, boolean interruptable) throws InterruptedException {
        if (isDone()) {
            return true;
        }

        if (timeoutNanos <= 0) {
            return isDone();
        }

        if (interruptable && Thread.interrupted()) {
            throw new InterruptedException(toString());
        }

        checkDeadLock();

        // Start counting time from here instead of the first line of this method,
        // to avoid/postpone performance cost of System.nanoTime().
        final long startTime = System.nanoTime();
        synchronized (this) {
            boolean interrupted = false;
            try {
                long waitTime = timeoutNanos;
                while (!isDone() && waitTime > 0) {
                    incWaiters();
                    try {
                        wait(waitTime / 1000000, (int) (waitTime % 1000000));
                    } catch (InterruptedException e) {
                        if (interruptable) {
                            throw e;
                        } else {
                            interrupted = true;
                        }
                    } finally {
                        decWaiters();
                    }
                    // Check isDone() in advance, try to avoid calculating the elapsed time later.
                    if (isDone()) {
                        return true;
                    }
                    // Calculate the elapsed time here instead of in the while condition,
                    // try to avoid performance cost of System.nanoTime() in the first loop of while.
                    waitTime = timeoutNanos - (System.nanoTime() - startTime);
                }
                return isDone();
            } finally {
                if (interrupted) {
                    Thread.currentThread().interrupt();
                }
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does await0() do?
await0() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/DefaultPromise.java.
Where is await0() defined?
await0() is defined in common/src/main/java/io/netty/util/concurrent/DefaultPromise.java at line 691.
What does await0() call?
await0() calls 4 function(s): checkDeadLock, decWaiters, incWaiters, isDone.
What calls await0()?
await0() is called by 2 function(s): await, awaitUninterruptibly.

Analyze Your Own Codebase

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

Try Supermodel Free