3 ms·
Agreed, that circular buffer thing is bound to do one of two things based on whether the RNG thread or the work thread is faster: a) work slower than RNG – do
by StefanKarpinski 13y ago
Agreed, that circular buffer thing is bound to do one of two things based on whether the RNG thread or the work thread is faster:
a) work slower than RNG – do too much work, wasting CPU;
b) work faster than RNG – produce very poor randomness.
Neither of these situations is good, and dealing with two threads in the first place is a bit of a complication. If you're going to do that, it's better to synchronize the two threads so that the work thread blocks when it needs more randomness than the RNG thread has produced and vice versa.