[Pool]: How to tag pool_allocator

Hello pool_allocator based on singleton allocator, but uses it's own tag. But I want use one pool_allocator for some strings/vectors/lists and another for some other data, because I want destroy data separately. Is it possible now? Or may be I do it wrong?

From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of VoidEx Sent: Thursday, October 23, 2008 1:18 PM
But I want use one pool_allocator for some strings/vectors/lists and another for some other data, because I want destroy data separately.
One thing to keep in mind is that the singleton_pool underneath pool_allocator is differentiated not only based on the tag (which, as you observe, is fixed in the case of pool_allocator) but also on the size of elements to be allocated. This means that under at least some circumstances, there will be multiple singleon_pools servicing a _single_ STL container; std::list being the most obvious case. This makes it difficult to interact directly with the singleton_pool(s) for a given container. That said, there doesn't seem to be any reason why we could not expose the tag used by pool_allocator (and fast_pool_allocator) to parameterization. The result might look something like this: template <typename T, typename UserAllocator = default_user_allocator_new_delete, typename Mutex = boost::mutex, unsigned NextSize = 32, typename Tag = pool_allocator_tag> class pool_allocator; Would that do what you want? -Chris

That said, there doesn't seem to be any reason why we could not expose the tag used by pool_allocator (and fast_pool_allocator) to parameterization. The result might look something like this:
template <typename T, typename UserAllocator = default_user_allocator_new_delete, typename Mutex = boost::mutex, unsigned NextSize = 32, typename Tag = pool_allocator_tag> class pool_allocator;
Would that do what you want?
I suppose no, because there still may be several underneath singleton_pools, so i wouldn't be able to release all memory, allocated by this allocator. Thanks for your reply. I will try to find other ways, how to solve it. VoidEx
participants (2)
-
Chris Newbold
-
VoidEx