You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When could we get more then two active mutable references to `thread_rng`?
82
+
Normally there are only mutable references to the RNG inside `UnsafeCell` inside `next_u32`, `next_u64` etc. Within a single thread (which is the definition of `ThreadRng`), there will only ever be one of these functions active at a time.
83
+
84
+
A possible scenario where there could be multiple mutable references is if `ThreadRng` is used _inside_ `next_u32` and co. But the three parts that make up `ThreadRng`, a PRNG, `EntropyRng` and the `ReseedingRng` wrapper are all under our control. We just have to ensure none of them use `ThreadRng` internally, which is nonsensical anyway.
85
+
86
+
Another possible option might be if we where in the middle of `next_u32` (and co.), another thread panics, in this thread destructors start to run, and the destructors make use of `ThreadRng`. Is this a real problem or does panicking work differently?
0 commit comments