[Boost-bugs] [Boost C++ Libraries] #4277: Ease access to underlying singleton_pool

Subject: [Boost-bugs] [Boost C++ Libraries] #4277: Ease access to underlying singleton_pool
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-06-01 14:38:19


#4277: Ease access to underlying singleton_pool
----------------------------------------------+-----------------------------
 Reporter: Henning.Stroeker@… | Owner: cnewbold
     Type: Feature Requests | Status: new
Milestone: Boost 1.43.0 | Component: pool
  Version: Boost 1.44.0 | Severity: Optimization
 Keywords: |
----------------------------------------------+-----------------------------
 It is not convenient to call ''singleton_pool<...>::release_memory()'' if
 you use
 ''pool_allocator'' or ''fast_pool_allocator''. The reason is that the
 exact singleton_pool type has to be specified:
 {{{
 typedef boost::pool_allocator<int> myAllocator;
 std::vector<int, myAllocator> v;
 ... //do something and empty v again
 boost::singleton_pool<boost::pool_allocator_tag,
 sizeof(int)>::release_memory();
 }}}
 In fact the call to ''release_memory'' might need even more template
 arguments (because of user allocators etc). And: The developer has to know
 all template parameters. If the vector declaration changes the call to
 ''release_memory'' has to be changed too, otherwise it would still compile
 but have no effect. This is error-prone.
 It would be much easier if ''pool_allocator'' and ''fast_pool_allocator''
 would provide a typedef for the used singleton_pool. Then the above code
 would look like this:
 {{{
 typedef boost::pool_allocator<int> myAllocator;
 std::vector<int, myAllocator> v;
 ... //do something and empty v again
 myAllocator::singleton_pool_type::release_memory();
 }}}

 The implementation in pool_alloc.hpp would look like this:

 {{{

 template <typename T,
     typename UserAllocator,
     typename Mutex,
     unsigned NextSize>
 class pool_allocator
 {
   public:
     typedef T value_type;
     typedef UserAllocator user_allocator;
     typedef Mutex mutex;

     ...

     typedef singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator,
 Mutex, NextSize> singleton_pool_type;

 ...
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4277>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC