Boost logo

Boost :

From: Andy (atompkins_at_[hidden])
Date: 2007-06-04 13:18:16

Other than the current approach (which I agree is not acceptable), I see
6 alternatives to the uuid::create() function. I believe all of them
have been mentioned before.

1. Make the random number generator a static object. Document the
function as not thread safe. This will be fast, but easy to use
incorrectly (e.g. in a multi-threaded program).

2. Make the random number generator a static object and protect calls to
it with a mutex. This is a thread safe solution, but it will be slow
because of the mutex.

3. Make the random number generator live in thread local storage. This
will be a thread safe solution, but requires Boost.Thread.

4. Use the current seed as the random numbers directly. Will this
solution provide 'good' uuids? That is, is this source of random numbers
good enough?

5. Create a function object (that has the random number generator as a
member) that produces uuids. Is this too complicated?
class uuid_generator {
  uuid_generator() {
  uuid operator() const;
  Engine& engine;

6. Create a CAS/lock-free random number generator. This is hard to

I am favoring number 4, unless it will not produce good uuids. Then I
favor number 5.

I guess I am looking for direction as to how to proceed.


Boost list run by bdawes at, gregod at, cpdaniel at, john at