Boost logo

Boost :

Subject: Re: [boost] [uuids] generating uuids from multiple threads
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-01-09 22:27:23


On Fri, Jan 9, 2009 at 19:11, Michael Marcin <mike.marcin_at_[hidden]> wrote:
>
> How expensive is it in terms of memory to store a static or thread local
> uuid_generator for the length of the program? I only expect this to be
> called maybe twice. The application will run on memory constrained mobile
> devices.
>

The random-based generator is essentially just a wrapper on the
(P)RNG, so it'll take as much storage as the PRNG. (v13 stores the
variate generator too, but I think that'll change, since afaik that's
cheap to construct.)

There's a nice table with memory requirements here:
http://www.boost.org/doc/libs/1_37_0/libs/random/random-generators.html#intro

So while the default PRNG needs 625*sizeof(uint32_t) of state, you
could use a basic_uuid_generator<rand48>, which will need only 64 bits
of storage. (Plus apparently at least 64 bits for the generator, but
you can get rid of that easily enough by changing the uuid generator
to construct it on demand.)

~ Scott


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk