Boost logo

Boost :

From: Johan Torp (johan.torp_at_[hidden])
Date: 2007-09-19 09:20:40


>> 1. More informative class and method names
>
>Well, the name heap makes me think of a certain kind of memory
>management system. Probably a name like Keepalive_bucket would
>be clearer?

Yes! There are probably even better names. Names might involve
manual/garbage collection, owner, life time [synchronizer],
delayed/synchronized destruction/or, respirator, reaper, .. well, probably
getting a bit too creative here :) I'd love more suggestions/opinions
though!

>> 5. Raw pointers can be handled more efficiently than shared_ptrs
>
>But think of it - if that pointed-to object is in use by some other
>means, it would be destroyed by the heap destructor nevertheless.

Creating a shared_ptr from a raw pointer has the same "problem". If users
fail to realize this, they've misunderstood the whole point of the class.

>An (untested) wrapper class I would start with would be something like:
>
>class Keepalive: private boost::noncopyable {
> Std::vector< boost::shared_ptr<void> > v;
>public:
> template <typename T> void put(boost::shared_ptr<T> p) {
>v.push_back(p); };
> template <typename T> void put(std::auto_ptr<T>& p) {
>v.push_back(boost::shared_ptr<T>(p)); };
> template <typename T> void put(T *p) {
>v.push_back(boost::shared_ptr<T>(p)); };
>};
>
>Does that solve your needs?

Yes, this is basically what the implementation I'm using today I looks like.
The question is if anybody else finds it useful.

Again - thanks for your input!

Johan

-- 
View this message in context: http://www.nabble.com/RFC---lifetime-management-tf4425074.html#a12777199
Sent from the Boost - Dev mailing list archive at Nabble.com.

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