February 14, 2009 Re: default random object? | ||||
|---|---|---|---|---|
| ||||
Walter Bright Wrote: > Andrei Alexandrescu wrote: > > 2. The global random generator will be allocated per thread. Are you cool with this too? > > That could have speed problems with a tight loop accessing thread local storage. If it's a shared global with no locking, the thread randomness will increase its randomness <g>. Lately, I wonder why TLS is treated as special and globals are normal. I don't know enough about threading models on various platforms to fully understand the implications. I've already been tempted to move some of my multi-threaded D code to multi-process for the benefits it offers (mostly efficient garbage collection when scaling to 8+ threads. My use of shared memory is minimal and easily eliminated. > > 3. How should the global rng be initialized? To always generate the same sequence, or not? > > Always different, because that's what I want if I just want a freakin' random number! | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply