lundi 21 mai 2018

Concurrent use of random number distribution (C++)

I think the answer applies to all random number distributions, so let's just take uniform_int_distribution for example.

I have an array of random number engines eng, with eng[i] for the use of thread i. Is it OK if I use a single uniform_int_distribution dist, and call dist(eng[i]) concurrently from the threads? Also, I want to make sure that using a single distribution instance like this does not correlate the number series generated for different threads.

I'm concerned because operator() is not marked const:

template< class Generator >
result_type operator()( Generator& g );

Aucun commentaire:

Enregistrer un commentaire