dev  

Re: Changing the order of cleanup for some core objects

Bojan Smojver
Wed, 23 Jul 2008 03:12:36 -0700

On Wed, 2008-07-23 at 11:23 +0200, Mladen Turk wrote:

> Well but what if I need that pool in destructor?
> It'll be long gone before destructor is called.

That's the whole "design pattern" argument. If you follow the "design
pattern", you won't need it there.

> IMHO reslist should do what is says:
> For each resource there is constructor/destructor and it's
> the API user responsibility to cleanup any resources in
> destructor that have been allocated in the constructor.
> ... very nice, simple and clean thought.

Well, maybe so. Some others would argue that giving people API where you
simply register cleanups as you normally would in APR is a better thing
to do.

Matter of taste and preference, I guess.

PS. In all honesty, even telling people to malloc()/free() their
resource container and reset any sub-pool pointers in the cleanup
registered in the constructor, would be good enough solution for me.

PPS. The implementation of Joe's proposal can be put into something we
may call respool (as opposed to reslist), so that people can choose that
if they so wish.

-- 
Bojan