nextLong() — netty Function Reference
Architecture documentation for the nextLong() function in ThreadLocalRandom.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b776a5b2_2836_d36a_601c_20ffeadcb95d["nextLong()"] cad32658_3724_a99b_a2c9_78d6688e22b6["ThreadLocalRandom"] b776a5b2_2836_d36a_601c_20ffeadcb95d -->|defined in| cad32658_3724_a99b_a2c9_78d6688e22b6 bbbaa728_e140_8728_d47e_e3846f949988["next()"] b776a5b2_2836_d36a_601c_20ffeadcb95d -->|calls| bbbaa728_e140_8728_d47e_e3846f949988 50844849_8964_e3f4_f90b_e3092753567c["nextInt()"] b776a5b2_2836_d36a_601c_20ffeadcb95d -->|calls| 50844849_8964_e3f4_f90b_e3092753567c style b776a5b2_2836_d36a_601c_20ffeadcb95d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java lines 317–336
public long nextLong(long n) {
checkPositive(n, "n");
// Divide n by two until small enough for nextInt. On each
// iteration (at most 31 of them but usually much less),
// randomly choose both whether to include high bit in result
// (offset) and whether to continue with the lower vs upper
// half (which makes a difference only if odd).
long offset = 0;
while (n >= Integer.MAX_VALUE) {
int bits = next(2);
long half = n >>> 1;
long nextn = ((bits & 2) == 0) ? half : n - half;
if ((bits & 1) == 0) {
offset += n - nextn;
}
n = nextn;
}
return offset + nextInt((int) n);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does nextLong() do?
nextLong() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java.
Where is nextLong() defined?
nextLong() is defined in common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java at line 317.
What does nextLong() call?
nextLong() calls 2 function(s): next, nextInt.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free