Thursday, 19 September 2013

Is boost::uuids::random_generator thread safe?

Is boost::uuids::random_generator thread safe?

Consider this function compiling with g++ -std=c++11 (GCC 4.7.2):
boost::uuids::uuid getID()
{
static boost::uuids::random_generator generator;
return generator();
}
Is it safe to call getID from multiple threads?
As it is mentioned here the local static object definition at the first
line is thread safe according to the C++11 standard. The question is if
the call to boost::uuids::random_generator::operator() on the same object
generator at the second line is also thread safe. Will the returned UUIDs
be unique in the sense they would be in a single thread?

No comments:

Post a Comment