Re: RFC: getting a unique integer value


Subject: Re: RFC: getting a unique integer value
From: Patrick Lam (plam@plam.lcs.mit.edu)
Date: Sat Oct 13 2001 - 12:47:53 CDT


On Sun, 14 Oct 2001, Martin Sevior wrote:

> On Fri, 12 Oct 2001, Matti Picus wrote:
>
> > Generating a unique int ID seems to be faulty in many places in AbiWord.
> > The general method is to use the result from UT_rand() and hope that it is
> > unique.
>
> Thanks to Pat Lam we have a great XP random number generator. This will on
> average give you an identical random number one in 2^32 attempts. That's
> approximately 1 in 4,000,000,000 attempts so we're pretty safe :-)

Yes, I used the random number generator from some library.

If you get a collision with two numbers returned from UT_rand in a 32-bit
address space, you've got other things to worry about; it's far more
likely that you'll get hit by a truck, or your roof will spontaneously
cave in.

Keeping a counter introduces other problems too. You need to lock your
counter (to prevent problems with concurrency), etc. And it won't make
you do better.

pat



This archive was generated by hypermail 2b25 : Sat Oct 13 2001 - 12:48:20 CDT