From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2008-01-29 20:57:29
This is not a review of the library, rather a wish list.
(I started to read it only now.)
1. (Not important) I personally would like
a different name: "const_singleton" so.
2. There should be macro BOOST_FLYWEIGHT_NOT_USED
which would disable functionality of the library
so that flyweight<std::string> would become std::string
- for troubleshooting and performance tests.
An ability to disable flyweightness per type or tag would be useful.
3. More support for troubleshooting. I would like to see
something as macro BOOST_FLYWEIGHT_PARANOIC_MODE
where each factory instantiates 2 objects with the same value
and the holder returns one or the other, alternating them
over and over where possible.
This should help to detect wrong use of the flyweight.
4. Support for unit tests run within application session.
I would like to see something as:
... use flyweight, e.g. create zillion different values in a stress
Possibly an ability to temporarily preserve current instances
owned by the specified holder, make the holder emply and
on exit from the unit test restore the initial state.
Ideally, I should have a way to do this with _all_ flyweight holders
in the applications, w/o need to specify them explicitly.
5. (This is a biggie) Ability for the end user to specify somewhere
the set of allowed shared values created by the factory,
by enumeration or with a constraint on those values
(only the surnames "Smith", "Jones", "Jackson" and those starting with
so all other values would be created and used as nonshared.
The effects would be:
* reduction of the possible unlimited growth of the stored instances,
* locking and reference counting overhead for values too hard
to share would be eliminated.
6. An API (possibly just in debug mode) which provides usage statistics
for a flyweighted type (where available).
7. For people who learn from examples: the more of them the better.
The documentation could have a section about potential
disadvantages of flyweights.