Protect KIID generator from threading
This commit is contained in:
parent
016a98df86
commit
572747a3f9
|
@ -33,8 +33,12 @@
|
|||
#include <boost/uuid/entropy_error.hpp>
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
// boost:mt19937 is not thread-safe
|
||||
static std::mutex rng_mutex;
|
||||
|
||||
// Create only once, as seeding is *very* expensive
|
||||
static boost::mt19937 rng;
|
||||
|
@ -69,9 +73,14 @@ KIID::KIID()
|
|||
#endif
|
||||
|
||||
if( createNilUuids )
|
||||
{
|
||||
m_uuid = nilGenerator();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( rng_mutex );
|
||||
m_uuid = randomGenerator();
|
||||
}
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue