Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/random.hpp"
Adapter to protect against data corruption caused by concurrent access.
Random number generators in general are not thread safe; when used from several threads concurrently, it is not a question if, but only a question when the internal state will become corrupted, leading to degraded and biased distributions of produced numbers. For some usage scenarios however, ignoring this fact and still using a single generator from several threads may be acceptable, if the quality of the distribution actually does not matter and only some diffusion of numbers is required (e.g. adding a random sleep interval). But there is a catch: whenever the value range of generated numbers is less than the total range of the used data representation, then corruption of the internal state may lead to producing numbers outside the defined range. This adapter can be used to safeguard against this scenario.
Definition at line 277 of file random.hpp.
Public Member Functions | |
GEN::result_type | operator() () |