Class EntropyBlockingSplittableRandomAdapter

    • Constructor Detail

      • EntropyBlockingSplittableRandomAdapter

        public EntropyBlockingSplittableRandomAdapter​(SimpleRandomSeeder randomSeeder,
                                                      long minimumEntropy)
        Creates an instance.
        Parameters:
        randomSeeder - the SimpleRandomSeeder that will reseed this. Its seed generator is also used on the calling thread to generate an initial seed when this EntropyBlockingSplittableRandomAdapter is used the first time on each thread.
        minimumEntropy - the minimum entropy; operations that would drop the entropy below this amount will instead block until the calling thread's PRNG is reseeded. Should generally be zero or negative.
      • EntropyBlockingSplittableRandomAdapter

        public EntropyBlockingSplittableRandomAdapter​(@Nullable
                                                      SeedGenerator seedGenerator,
                                                      SimpleRandomSeeder randomSeeder,
                                                      long minimumEntropy)
        Creates an instance.
        Parameters:
        seedGenerator - the seed generator that will generate an initial PRNG seed for each thread
        randomSeeder - the SimpleRandomSeeder that will reseed this
        minimumEntropy - the minimum entropy; operations that would drop the entropy below this amount will instead block until the calling thread's PRNG is reseeded. Should generally be zero or negative.
    • Method Detail

      • setSeed

        public void setSeed​(long seed)
        Sets the seed of this random number generator using a single long seed, if this implementation supports that. If it is capable of using 64 bits or less of seed data (i.e. if {@link #getNewSeedLength()} <= {@link Long#BYTES}), then this method shall replace the entire seed as Random.setSeed(long) does; otherwise, it shall either combine the input with the existing seed as SecureRandom.setSeed(long) does, or it shall generate a new seed using the DefaultSeedGenerator. The latter is a backward-compatibility measure and can be very slow. Applies only to the calling thread.
        Specified by:
        setSeed in interface Java8CompatRandom
        Overrides:
        setSeed in class BaseRandom
      • getSplittableRandom

        protected java8.util.SplittableRandom getSplittableRandom()
        Description copied from class: BaseSplittableRandomAdapter
        Returns the SplittableRandom that is to be used to generate random numbers for the current thread. (SplittableRandom isn't thread-safe.) Called by all the next* methods.
        Overrides:
        getSplittableRandom in class SplittableRandomAdapter
        Returns:
        the SplittableRandom to use with the current thread.
      • debitEntropy

        protected void debitEntropy​(long bits)
        Description copied from class: BaseRandom
        Record that entropy has been spent, and schedule a reseeding if this PRNG has now spent as much as it's been seeded with.
        Overrides:
        debitEntropy in class SplittableRandomAdapter
        Parameters:
        bits - The number of bits of entropy spent.