|
Boost : |
From: Andy (atompkins_at_[hidden])
Date: 2007-02-27 11:44:35
<Oliver.Kowalke_at_[hidden]> wrote in
news:B1EAFF2DAE7658488B631F25813CD91FD388B7_at_[hidden]:
> Hello Andy,
>
>> I am not very happy with the create_v1() function in
>> guid_v3.zip. Really it just pretends to implement the
>> specification correctly.
> Because MAC-address of the nic isn't used?
Yes, because the MAC-address is not used which increases the probability of
duplicates.
Also my implementation does not use stable storage and this is the least desirable
implementation, because it will increase the frequency of creation of new clock
sequence numbers, which increases the probability of duplicates.
< snip >
> How is your implementation of uuid v4 unique in space (guids
> genereated on several computers at the same time) and time?
My implementation of version 4 (random-number-based) guids may not be unique in space
and time. It is based on boost::mt19937 to generate random numbers and it is seeded
with std::time(0). Cryptographic-quality random numbers would reduce the probability
of repeated values.
Using version 5 (name-based) guid can be used to ensure that guids are unique in space
(guids generated on several computers at the same time) and time. Generate a guid for
each computer as the namespace_guid and pass a counter as the name to the create
function.
example: (not tested or compiled)
const static guid computer_namespace_guid("{00000000-0000-0000-0000-000000000000}");
// or some other guid that never changes
guid generate_guid()
{
// get unique string for computer
// could be mac address
const char* computer_name = get_unique_computer_name();
const static guid namespace_guid
= guid::create(computer_namespace_guid, computer_name,
strlen(computer_name));
static int count = 0;
guid result = guid::create(namespace_guid,
static_cast<char*>(&count), 4);
++count;
return result;
}
>
> Regards, Oliver
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
Andy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk