On Fri, 2007-08-24 at 11:52 -0700, JT Moree wrote:
> JT Moree wrote:
> > 
> > Is this uique enough?  what is the chance of getting the same random
> > number again?  should it be a combination of the PID + time + rand?
> > 
> 
> my @sname = split(/\./, $self->qp->config("me"));
> = $sname[0].$$.'r'.int( (( time ^ $$ ) * rand($$)) / rand(time/$$));
> 
> = sprintf("%08X", rand(2**32 - 1));
> 
> $self->qp->config("me") =~ m/\.(\d{1,3}$/;  #not tested
> $self->{_id} = $1;
> = sprintf("%.4f%d", time(), $self->{_id});
> 
> = sprintf("%.4f", time()) .".". $self->qp->config("me") . \
>   sprintf("%08X", rand(2**32 - 1));  #how expensive is this?
> 
> These are the approaches suggested so far.  I added the last one as a
> combination of the others.  Can we see a show of hands for the one

Using rand is bogus.  A random number generator will repeat values.

Time (with sufficient resolution) is equivalent to a sequence ... but
with threads, you would need a lock on the sequence generator.

> people like the best?
> 
> Can we get Hanno to modify his patch if people like one of these
> approaches?  Can we get it tested by some people?  Can we get it checked
> into svn?

-- 
--gh


Reply via email to