Re: [boost] [uuid] uuid::create() is extremely slow

From: Andy <atompkins@fastmail.fm>
There was opposition to using static objects because of threading concerns. I do want a function that doesn't require the user to create a random number generator themselves.
If I use a static engine, I need to protect it with a mutex. This is not optimal because there is the overhead of locking and unlocking the mutex. Some people would rather have a static engine per thread using thread local storage. This still requires one to link with Boost.Thread. I created the uuid::create(Engine) function (great advice from this list) so that users could do whatever they want (static engine per thread, use thread local storage,...).
The uuid::create() function should handle the common case and not be best for all situations. So, I guess I need help to determine what the common case is.
My vote is to use a static in uuid::create() for performance, put in the documentation that this function is not thread-safe, and simply require that applications that care about thread safety for UUID creation use the uuid::create(Engine) interface. Developers going from a non-threaded to a threaded application are going to have to audit their code for thread safety anyway. - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837
participants (1)
-
james.jonesīŧ firstinvestors.com