pub struct ThreadLocalRngPool { /* private fields */ }Expand description
Thread-local random number generator pool
Provides deterministic, thread-safe random number generation by maintaining separate RNG instances for each thread, seeded in a predictable manner.
Implementations§
Source§impl ThreadLocalRngPool
impl ThreadLocalRngPool
Sourcepub fn new(seed: u64) -> ThreadLocalRngPool
pub fn new(seed: u64) -> ThreadLocalRngPool
Create a new thread-local RNG pool with a specific seed
This ensures deterministic behavior across parallel executions when the same base seed is used.
Sourcepub fn new_time_seeded() -> ThreadLocalRngPool
pub fn new_time_seeded() -> ThreadLocalRngPool
Create a thread-local RNG pool with a seed derived from system time
Sourcepub fn get_rng(&self) -> Random<StdRng>
pub fn get_rng(&self) -> Random<StdRng>
Get a thread-local RNG
Each call to this method returns a new RNG instance seeded with a deterministic value based on the base seed and thread counter.
Sourcepub fn with_rng<F, R>(&self, f: F) -> R
pub fn with_rng<F, R>(&self, f: F) -> R
Execute a closure with a thread-local RNG
This is the preferred way to use the thread-local RNG pool as it ensures proper resource management and consistent seeding.
Sourcepub fn thread_counter(&self) -> usize
pub fn thread_counter(&self) -> usize
Get the current thread counter value
Sourcepub fn reset_counter(&self)
pub fn reset_counter(&self)
Reset the thread counter (useful for reproducible testing)
Trait Implementations§
Source§impl Debug for ThreadLocalRngPool
impl Debug for ThreadLocalRngPool
Source§impl Default for ThreadLocalRngPool
impl Default for ThreadLocalRngPool
Source§fn default() -> ThreadLocalRngPool
fn default() -> ThreadLocalRngPool
Auto Trait Implementations§
impl Freeze for ThreadLocalRngPool
impl RefUnwindSafe for ThreadLocalRngPool
impl Send for ThreadLocalRngPool
impl Sync for ThreadLocalRngPool
impl Unpin for ThreadLocalRngPool
impl UnsafeUnpin for ThreadLocalRngPool
impl UnwindSafe for ThreadLocalRngPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more