diff options
Diffstat (limited to 'tokio/src/util/rand.rs')
-rw-r--r-- | tokio/src/util/rand.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tokio/src/util/rand.rs b/tokio/src/util/rand.rs index 11617e26..101f5bb6 100644 --- a/tokio/src/util/rand.rs +++ b/tokio/src/util/rand.rs @@ -50,3 +50,16 @@ impl FastRand { s0.wrapping_add(s1) } } + +// Used by the select macro +cfg_macros! { + thread_local! { + static THREAD_RNG: FastRand = FastRand::new(crate::loom::rand::seed()); + } + + // Used by macros + #[doc(hidden)] + pub fn thread_rng_n(n: u32) -> u32 { + THREAD_RNG.with(|rng| rng.fastrand_n(n)) + } +} |