Boost logo

Boost Users :

From: scleary_at_[hidden]
Date: 2002-12-05 15:23:48


> if construct only, and freeall in ~object_pool. i think it is good.

Yes. The destuctor of object_pool will call the destructor of each
allocated or constructed object that has not yet been deallocated or
destroyed.

> can i use object_pool to replace 'new delete'?

object_pool provides object-based allocation and deallocation, very similar
to new and delete.

> the destroy is slow.

Destroying single objects that were created from an object_pool uses
ordered_free, as you discovered. An object_pool will keep its free list
ordered, so that it can run through the "list of allocated objects" in O(N)
time instead of O(N**2) time in ~object_pool. It's a performance tradeoff
with object_pool::destroy; object_pool was designed more for a "allocate a
bunch of objects and then destroy all of them" type of scenario.

        -Steve


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net