getInitialSeedUniquifier() — netty Function Reference
Architecture documentation for the getInitialSeedUniquifier() function in ThreadLocalRandom.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 934f1d75_fad9_3323_2acb_33ba4aa751de["getInitialSeedUniquifier()"] cad32658_3724_a99b_a2c9_78d6688e22b6["ThreadLocalRandom"] 934f1d75_fad9_3323_2acb_33ba4aa751de -->|defined in| cad32658_3724_a99b_a2c9_78d6688e22b6 6aab6f7b_9b36_71ef_c98a_e545b4b09e28["newSeed()"] 6aab6f7b_9b36_71ef_c98a_e545b4b09e28 -->|calls| 934f1d75_fad9_3323_2acb_33ba4aa751de style 934f1d75_fad9_3323_2acb_33ba4aa751de fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java lines 129–197
public static long getInitialSeedUniquifier() {
// Use the value set via the setter.
long initialSeedUniquifier = ThreadLocalRandom.initialSeedUniquifier;
if (initialSeedUniquifier != 0) {
return initialSeedUniquifier;
}
synchronized (ThreadLocalRandom.class) {
initialSeedUniquifier = ThreadLocalRandom.initialSeedUniquifier;
if (initialSeedUniquifier != 0) {
return initialSeedUniquifier;
}
// Get the random seed from the generator thread with timeout.
final long timeoutSeconds = 3;
final long deadLine = seedGeneratorStartTime + TimeUnit.SECONDS.toNanos(timeoutSeconds);
boolean interrupted = false;
for (;;) {
final long waitTime = deadLine - System.nanoTime();
try {
final Long seed;
if (waitTime <= 0) {
seed = seedQueue.poll();
} else {
seed = seedQueue.poll(waitTime, TimeUnit.NANOSECONDS);
}
if (seed != null) {
initialSeedUniquifier = seed;
break;
}
} catch (InterruptedException e) {
interrupted = true;
logger.warn("Failed to generate a seed from SecureRandom due to an InterruptedException.");
break;
}
if (waitTime <= 0) {
seedGeneratorThread.interrupt();
logger.warn(
"Failed to generate a seed from SecureRandom within {} seconds. " +
"Not enough entropy?", timeoutSeconds
);
break;
}
}
// Just in case the initialSeedUniquifier is zero or some other constant
initialSeedUniquifier ^= 0x3255ecdc33bae119L; // just a meaningless random number
initialSeedUniquifier ^= Long.reverse(System.nanoTime());
ThreadLocalRandom.initialSeedUniquifier = initialSeedUniquifier;
if (interrupted) {
// Restore the interrupt status because we don't know how to/don't need to handle it here.
Thread.currentThread().interrupt();
// Interrupt the generator thread if it's still running,
// in the hope that the SecureRandom provider raises an exception on interruption.
seedGeneratorThread.interrupt();
}
if (seedGeneratorEndTime == 0) {
seedGeneratorEndTime = System.nanoTime();
}
return initialSeedUniquifier;
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getInitialSeedUniquifier() do?
getInitialSeedUniquifier() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java.
Where is getInitialSeedUniquifier() defined?
getInitialSeedUniquifier() is defined in common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java at line 129.
What calls getInitialSeedUniquifier()?
getInitialSeedUniquifier() is called by 1 function(s): newSeed.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free