
8 Oct
2006
8 Oct
'06
11:21 a.m.
----- Mensaje original ----- De: Janek Kozicki <janek_listy@wp.pl> Fecha: Domingo, Octubre 8, 2006 0:12 am Asunto: Re: [boost] flyweight library? Para: boost@lists.boost.org > Joaquín M_ López Mu_oz said: (by the date of Fri, 06 Oct 2006 > 07:48:22 +0200) > > > Janek Kozicki ha escrito: > 2. a Typo in libs/flyweight/doc/tutorial/holders.html: > > "For instance, flyweight<T> is equivalent to" > ^^^ Thank you, will fix it. > 3. am I right to think that: > > flyweight<std::string,hashed_factory<>,global_holder<unsigned > char> > > > will allow me to have 255 different strings, while > > flyweight<std::string,hashed_factory<>,global_holder<unsigned > short> > > > will allow me to have 65535 ? Emm, no, that's not correct. The holder is used to maintain a unique copy of the flyweight factory, its role is very similar to that of a singleton. Nothing to do with controlling the capacity of the factory. > > > 4. have you ever thought about sample usage of flywieght to create > a new > boost library: boost::flyweight_shared_ptr<T> ? > > The problem it tries to solve is that on amd64 each pointer > consumes 64 > bits (8 bytes!), when people make a switch from 32bits to 64bits, this > hurts badly. In my calculations memory usage grew from 700MB to 1.3GB, > and that actually makes a difference. (it's not possible to run > calculations if some of the data must swap to disc...) > > hmm... maybe this will actually work: > > boost::flyweight<boost::shared_ptr<T> > > > will it? Well, the short answer is that flyweight won't gain you nothing wrt to shared_ptr, since flyweight objects contain a pointer (much like shared_ptr's) which is 8 bytes in 64bit architectures. The long answer is, given the flexibility that the componentized nature of flyweight allows, it is possible to devise a factory adaptor that limits the capacity of the factory *and* let the flyweight object use internally a handle value smaller in size than a pointer (an index of size unsigned short, for instance). I will try to write something along this line, I'll keep you informed. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo