Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54297 - in sandbox/monotonic: boost/monotonic boost/monotonic/container boost/monotonic/detail boost/utility libs/monotonic/test libs/monotonic/test/Tests
From: christian.schladetsch_at_[hidden]
Date: 2009-06-24 00:32:31


Author: cschladetsch
Date: 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
New Revision: 54297
URL: http://svn.boost.org/trac/boost/changeset/54297

Log:
added reclaimable_storage<>

Added:
   sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp (contents, props changed)
Text files modified:
   sandbox/monotonic/boost/monotonic/allocator.hpp | 14 +++++++-------
   sandbox/monotonic/boost/monotonic/allocator_base.hpp | 17 ++++++++++-------
   sandbox/monotonic/boost/monotonic/container/chain.hpp | 2 +-
   sandbox/monotonic/boost/monotonic/container/deque.hpp | 12 ++++++------
   sandbox/monotonic/boost/monotonic/container/list.hpp | 14 +++++++-------
   sandbox/monotonic/boost/monotonic/container/map.hpp | 12 ++++++------
   sandbox/monotonic/boost/monotonic/container/set.hpp | 15 +++++++++------
   sandbox/monotonic/boost/monotonic/container/string.hpp | 7 ++++---
   sandbox/monotonic/boost/monotonic/container/vector.hpp | 18 ++++++++++++------
   sandbox/monotonic/boost/monotonic/detail/construct.hpp | 10 ++++++++++
   sandbox/monotonic/boost/monotonic/detail/link.hpp | 5 +++--
   sandbox/monotonic/boost/monotonic/fixed_storage.hpp | 5 +++++
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp | 7 ++++++-
   sandbox/monotonic/boost/monotonic/local.hpp | 2 +-
   sandbox/monotonic/boost/monotonic/shared_allocator.hpp | 14 +++++++-------
   sandbox/monotonic/boost/monotonic/shared_storage.hpp | 4 ++--
   sandbox/monotonic/boost/monotonic/static_storage.hpp | 10 +++++-----
   sandbox/monotonic/boost/monotonic/storage.hpp | 7 ++++++-
   sandbox/monotonic/boost/monotonic/storage_base.hpp | 2 ++
   sandbox/monotonic/boost/monotonic/thread_local_storage.hpp | 4 ++--
   sandbox/monotonic/boost/utility/iter_range.hpp | 12 ++++++------
   sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 16 ++++++++--------
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 4 ++++
   24 files changed, 169 insertions(+), 84 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator.hpp (original)
+++ sandbox/monotonic/boost/monotonic/allocator.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -30,13 +30,13 @@
                 struct allocator : allocator_base<T, allocator<T, Region, Access> >
                 {
                         typedef allocator_base<T, allocator<T, Region, Access> > Parent;
- using typename Parent::size_type;
- using typename Parent::difference_type;
- using typename Parent::pointer;
- using typename Parent::const_pointer;
- using typename Parent::reference;
- using typename Parent::const_reference;
- using typename Parent::value_type;
+ using BOOST_DEDUCED_TYPENAME Parent::size_type;
+ using BOOST_DEDUCED_TYPENAME Parent::difference_type;
+ using BOOST_DEDUCED_TYPENAME Parent::pointer;
+ using BOOST_DEDUCED_TYPENAME Parent::const_pointer;
+ using BOOST_DEDUCED_TYPENAME Parent::reference;
+ using BOOST_DEDUCED_TYPENAME Parent::const_reference;
+ using BOOST_DEDUCED_TYPENAME Parent::value_type;
 
                         template <class U>
                         struct rebind

Modified: sandbox/monotonic/boost/monotonic/allocator_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/allocator_base.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -36,6 +36,7 @@
                         typedef detail::Construct<detail::is_monotonic<T>::value> Construct;
 
                         BOOST_STATIC_CONSTANT(size_t, alignment = boost::aligned_storage<sizeof(T)>::alignment);
+
                 //private:
                         storage_base *storage;
 
@@ -67,29 +68,31 @@
                                 return reinterpret_cast<T *>(storage->allocate(num*sizeof(T), alignment));
                         }
 
- void deallocate(pointer, size_type)
+ void deallocate(pointer ptr, size_type num)
                         {
- // do nothing
+ storage->deallocate(ptr);//, num);
                         }
 
                         size_type max_size() const throw()
                         {
                                 if (!storage)
                                         return 0;
- //return storage->max_size()/(sizeof(T) + alignment);
                                 return storage->max_size()/sizeof(value_type);
                         }
 
                         void construct(pointer ptr)
                         {
- Construct::Given(ptr, static_cast<Derived *>(this));
- //new (ptr) T();
+ Construct::Given(ptr, DerivedPtr());
                         }
 
                         void construct(pointer ptr, const T& val)
                         {
- Construct::Given(ptr, val, static_cast<Derived *>(this));
- //new (ptr) T(val);
+ Construct::Given(ptr, val, DerivedPtr());
+ }
+
+ Derived *DerivedPtr()
+ {
+ return static_cast<Derived *>(this);
                         }
 
                         void destroy(pointer ptr)

Modified: sandbox/monotonic/boost/monotonic/container/chain.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/chain.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/chain.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -160,7 +160,7 @@
                                 Vector &vec = strands.back();
                                 size_t len = std::distance(F,L);
                                 vec.resize(len);
- typename Vector::iterator G = vec.begin();
+ BOOST_DEDUCED_TYPENAME Vector::iterator G = vec.begin();
                                 for (size_t N = 0; N < len; ++F, ++G)
                                         *G = *F;
                         }

Modified: sandbox/monotonic/boost/monotonic/container/deque.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/deque.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/deque.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -22,12 +22,12 @@
                         typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
                         typedef std::deque<T,Allocator> Impl;
 
- typedef typename Impl::iterator iterator;
- typedef typename Impl::const_iterator const_iterator;
- typedef typename Impl::size_type size_type;
- typedef typename Impl::value_type value_type;
- typedef typename Impl::reference reference;
- typedef typename Impl::const_reference const_reference;
+ typedef BOOST_DEDUCED_TYPENAME Impl::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME Impl::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME Impl::size_type size_type;
+ typedef BOOST_DEDUCED_TYPENAME Impl::value_type value_type;
+ typedef BOOST_DEDUCED_TYPENAME Impl::reference reference;
+ typedef BOOST_DEDUCED_TYPENAME Impl::const_reference const_reference;
 
                 private:
                         Impl impl;

Modified: sandbox/monotonic/boost/monotonic/container/list.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/list.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/list.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -43,12 +43,12 @@
                         typedef std::list<T, Allocator> List, Implementation;
                         typedef detail::container<std::list<T, Allocator> > Parent;
 
- typedef typename List::iterator iterator;
- typedef typename List::const_iterator const_iterator;
- typedef typename List::size_type size_type;
- typedef typename List::value_type value_type;
- typedef typename List::reference reference;
- typedef typename List::const_reference const_reference;
+ typedef BOOST_DEDUCED_TYPENAME List::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME List::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME List::size_type size_type;
+ typedef BOOST_DEDUCED_TYPENAME List::value_type value_type;
+ typedef BOOST_DEDUCED_TYPENAME List::reference reference;
+ typedef BOOST_DEDUCED_TYPENAME List::const_reference const_reference;
                         typedef list<T,Region,Access> This;
 
                 private:
@@ -140,7 +140,7 @@
 
                                 const size_t MAXBINS = 25;
                                 This temp(get_allocator());
- typename Allocator::template rebind<This>::other alloc_this(get_allocator());
+ BOOST_DEDUCED_TYPENAME Allocator::template rebind<This>::other alloc_this(get_allocator());
                                 This *bin_list = alloc_this.allocate(MAXBINS + 1);
                                 for (This *bin = bin_list; bin < bin_list + MAXBINS; ++bin)
                                 {

Modified: sandbox/monotonic/boost/monotonic/container/map.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/map.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/map.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -28,12 +28,12 @@
                         typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
 
                         typedef std::map<K,T,P,Allocator > Map, Implementation;
- typedef typename Map::iterator iterator;
- typedef typename Map::const_iterator const_iterator;
- typedef typename Map::mapped_type mapped_type;
- typedef typename Map::value_type value_type;
- typedef typename Map::key_type key_type;
- typedef typename Map::size_type size_type;
+ typedef BOOST_DEDUCED_TYPENAME Map::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME Map::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME Map::mapped_type mapped_type;
+ typedef BOOST_DEDUCED_TYPENAME Map::value_type value_type;
+ typedef BOOST_DEDUCED_TYPENAME Map::key_type key_type;
+ typedef BOOST_DEDUCED_TYPENAME Map::size_type size_type;
 
                 private:
                         Implementation impl;

Modified: sandbox/monotonic/boost/monotonic/container/set.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/set.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/set.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -24,11 +24,14 @@
                         typedef allocator<T,Region,Access> Allocator;
                         typedef P Predicate;
                         typedef std::set<T,P,Allocator > Set;
- typedef typename Set::iterator iterator;
- typedef typename Set::const_iterator const_iterator;
- typedef typename Set::value_type value_type;
- typedef typename Set::key_type key_type;
- typedef typename Set::size_type size_type;
+ typedef BOOST_DEDUCED_TYPENAME Set::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME Set::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME Set::value_type value_type;
+ typedef BOOST_DEDUCED_TYPENAME Set::key_type key_type;
+ typedef BOOST_DEDUCED_TYPENAME Set::size_type size_type;
+ typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
+ typedef detail::container<set<T,Region,P,Access> > Parent;
+
                 private:
                         Set impl;
 
@@ -80,7 +83,7 @@
 
                         void insert(const value_type& value)
                         {
- impl.insert(value);
+ impl.insert(Create::Given(this->Parent::get_storage(), value));
                         }
                         void erase(iterator first)
                         {

Modified: sandbox/monotonic/boost/monotonic/container/string.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/string.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/string.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -22,9 +22,9 @@
                         typedef allocator<Ch, Region,Access> Allocator;
                         typedef std::basic_string<Ch, Tr, Allocator> Impl;
                         typedef size_t size_type;
- typedef typename Impl::iterator iterator;
- typedef typename Impl::const_iterator const_iterator;
- typedef typename Impl::value_type value_type;
+ typedef BOOST_DEDUCED_TYPENAME Impl::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME Impl::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME Impl::value_type value_type;
 
                 private:
                         Impl impl;
@@ -54,6 +54,7 @@
                         string(const Ch *str, storage_base &store)
                                 : impl(str, store)
                         {
+// BOOST_STATIC_ASSERT((boost::same_type<default_region_tag, Region>::value));
                         }
                         template <class II>
                         string(II F, II L)

Modified: sandbox/monotonic/boost/monotonic/container/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/container/vector.hpp (original)
+++ sandbox/monotonic/boost/monotonic/container/vector.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -8,6 +8,7 @@
 
 #include <boost/monotonic/allocator.hpp>
 #include <boost/monotonic/container.hpp>
+#include <boost/interprocess/containers/list.hpp>
 
 namespace boost
 {
@@ -22,12 +23,12 @@
                         typedef detail::Create<detail::is_monotonic<T>::value, T> Create;
                         typedef std::vector<T,Allocator> Impl;
 
- typedef typename Impl::iterator iterator;
- typedef typename Impl::const_iterator const_iterator;
- typedef typename Impl::size_type size_type;
- typedef typename Impl::value_type value_type;
- typedef typename Impl::reference reference;
- typedef typename Impl::const_reference const_reference;
+ typedef BOOST_DEDUCED_TYPENAME Impl::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME Impl::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME Impl::size_type size_type;
+ typedef BOOST_DEDUCED_TYPENAME Impl::value_type value_type;
+ typedef BOOST_DEDUCED_TYPENAME Impl::reference reference;
+ typedef BOOST_DEDUCED_TYPENAME Impl::const_reference const_reference;
 
                 private:
                         Impl impl;
@@ -36,6 +37,11 @@
                         vector() { }
                         vector(Allocator const &A)
                                 : impl(A) { }
+ vector(vector const &other, Allocator A)
+ : impl(A)
+ {
+ impl = other.impl;
+ }
                         vector(size_t N, T const &X, Allocator A = Allocator())
                                 : impl(N,X,A) { }
                         template <class II>

Modified: sandbox/monotonic/boost/monotonic/detail/construct.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/construct.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/construct.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -52,6 +52,11 @@
                                 {
                                         return T();
                                 }
+ template <class Storage>
+ static T Given(Storage &, T const &X)
+ {
+ return T(X);
+ }
                         };
                         template <class T>
                         struct Create<true, T>
@@ -61,6 +66,11 @@
                                 {
                                         return T(storage);
                                 }
+ template <class Storage>
+ static T Given(Storage &storage, T const &X)
+ {
+ return T(X, storage);
+ }
                         };
                 }
                 namespace detail

Modified: sandbox/monotonic/boost/monotonic/detail/link.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/detail/link.hpp (original)
+++ sandbox/monotonic/boost/monotonic/detail/link.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -16,7 +16,7 @@
                 {
                         /// a link in the chain of heap-based memory buffers used by a storage<> structure
                         template <class Al>
- struct Link : storage_base
+ struct Link// : storage_base
                         {
                                 typedef Al CharAllocator;
 
@@ -31,7 +31,8 @@
                                 }
                                 template <class Al2>
                                 Link(Al2 const &al, size_t cap)
- : capacity(cap), cursor(0), buffer(0), alloc(typename Al2::template rebind<char>::other(al))
+ : capacity(cap), cursor(0), buffer(0)
+ , alloc(BOOST_DEDUCED_TYPENAME Al2::template rebind<char>::other(al))
                                 {
                                         buffer = alloc.allocate(capacity);
                                         if (buffer == 0)

Modified: sandbox/monotonic/boost/monotonic/fixed_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/fixed_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/fixed_storage.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -116,6 +116,11 @@
                                 return ptr + extra;
                         }
 
+ void deallocate(void *ptr)
+ {
+ // do nothing
+ }
+
                         size_t max_size() const
                         {
                                 return InlineSize;

Modified: sandbox/monotonic/boost/monotonic/forward_declarations.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/forward_declarations.hpp (original)
+++ sandbox/monotonic/boost/monotonic/forward_declarations.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -35,6 +35,7 @@
 
                 /// tags for different storage regions
                 struct default_region_tag { };
+ struct heap_region_tag { };
 
                 /// tags for different access types
                 struct default_access_tag { };
@@ -44,7 +45,7 @@
                 /// selector to create a storage type given accessor
                 namespace detail
                 {
- template <class Access>
+ template <class Region, class Access>
                         struct storage_type;
                 }
         
@@ -52,6 +53,10 @@
                 template <class Region = default_region_tag, class Access = default_access_tag>
                 struct local;
 
+ /// conventional, reclaimable storage
+ template <size_t InlineSize = 0, size_t MinHeapIncrement = 0, class Al = default_allocator>
+ struct reclaimable_storage;
+
                 /// thread-safe storage
                 template <size_t InlineSize = DefaultSizes::InlineSize
                         , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement

Modified: sandbox/monotonic/boost/monotonic/local.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/local.hpp (original)
+++ sandbox/monotonic/boost/monotonic/local.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -40,7 +40,7 @@
                         {
                                 reset();
                         }
- static typename StaticStorage::StorageType &get_storage()
+ static BOOST_DEDUCED_TYPENAME StaticStorage::StorageType &get_storage()
                         {
                                 return StaticStorage::get_storage();
                         }

Added: sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/reclaimable_storage.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -0,0 +1,194 @@
+// Copyright (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_MONOTONIC_RECLAIMABLE_STORAGE_HPP
+#define BOOST_MONOTONIC_RECLAIMABLE_STORAGE_HPP
+
+#include <algorithm>
+#include <boost/monotonic/fixed_storage.hpp>
+#include <boost/monotonic/detail/pool.hpp>
+#include <boost/monotonic/detail/link.hpp>
+#include <boost/unordered/unordered_set.hpp>
+
+namespace boost
+{
+ namespace monotonic
+ {
+ namespace detail
+ {
+ template <>
+ struct storage_type<heap_region_tag, default_access_tag>
+ {
+ template <size_t N, size_t M, class Al>
+ struct storage
+ {
+ typedef monotonic::reclaimable_storage<N,M,Al> type;
+ };
+ };
+ template <class Pair>
+ struct HashPairFirst
+ {
+ size_t operator()(Pair const &pair) const
+ {
+ return reinterpret_cast<size_t>(pair.first);
+ }
+ };
+ }
+
+ template <size_t InlineSize, size_t MinHeapIncrement, class Al>
+ struct reclaimable_storage : storage_base
+ {
+ typedef reclaimable_storage<InlineSize, MinHeapIncrement, Al> This;
+ typedef Al Allocator;
+ typedef BOOST_DEDUCED_TYPENAME Allocator::template rebind<char>::other CharAllocator;
+ typedef std::pair<char *, size_t> Allocation;
+ typedef boost::unordered_set<
+ Allocation
+ , detail::HashPairFirst<Allocation>
+ , std::less<Allocation>
+ , Allocator> Allocations;
+
+ private:
+ CharAllocator alloc;
+ Allocations allocations;
+
+ public:
+ reclaimable_storage()
+ {
+ }
+ reclaimable_storage(Allocator const &A)
+ : alloc(A)
+ {
+ }
+ ~reclaimable_storage()
+ {
+ release();
+ }
+
+ void reset()
+ {
+ }
+
+ void release()
+ {
+ reset();
+ BOOST_FOREACH(Allocation const &what, allocations)
+ {
+ alloc.deallocate(what.first, what.second);
+ }
+ allocations.clear();
+ }
+
+ void *allocate(size_t num_bytes, size_t /*alignment*/ = 1)
+ {
+ Allocation what;
+ what.first = alloc.allocate(num_bytes);//, alignment);
+ what.second = num_bytes;
+ allocations.insert(what);
+ return what.first;
+ }
+
+ void deallocate(void *ptr)
+ {
+ if (ptr == 0)
+ return;
+ char *cptr = (char *)ptr;
+ Allocations::iterator iter = allocations.find(Allocation(cptr, size_t(0)));
+ BOOST_ASSERT(iter != allocations.end());
+ if (iter != allocations.end())
+ {
+ allocations.erase(iter);
+ }
+ alloc.deallocate(cptr, 1);
+ }
+
+ size_t max_size() const
+ {
+ return (std::numeric_limits<size_t>::max)();
+ }
+
+ size_t remaining() const
+ {
+ return max_size();
+ }
+
+ size_t used() const
+ {
+ size_t total = 0;
+ BOOST_FOREACH(Allocation const &what, allocations)
+ {
+ total += what.second;
+ }
+ return total;
+ }
+
+ // ------------------------------------------------------------------------
+
+ template <class Ty>
+ Ty *uninitialised_create()
+ {
+ return reinterpret_cast<Ty *>(allocate_bytes<sizeof(Ty)>());
+ }
+
+ template <class Ty>
+ Ty &create()
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ construct(ptr, boost::is_pod<Ty>());
+ return *ptr;
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
+ {
+ // do nothing
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::false_type&)
+ {
+ new (ptr) Ty();
+ }
+
+ template <class Ty>
+ Ty &create(Ty const &X)
+ {
+ Ty *ptr = uninitialised_create<Ty>();
+ new (ptr) Ty(X);
+ return *ptr;
+ }
+
+ template <class Ty>
+ void destroy(Ty &object)
+ {
+ object.~Ty();
+ deallocate(&object, 1);
+ }
+
+ template <class Ty>
+ void destroy(Ty const &object)
+ {
+ destroy(const_cast<Ty &>(object));
+ }
+
+ template <size_t N>
+ char *allocate_bytes()
+ {
+ return allocate_bytes(N, boost::aligned_storage<N>::alignment);
+ }
+
+ char *allocate_bytes(size_t num_bytes, size_t alignment = 1)
+ {
+ return reinterpret_cast<char *>(allocate(num_bytes, alignment));
+ }
+ };
+
+ } // namespace monotonic
+
+} // namespace boost
+
+#endif // BOOST_MONOTONIC_RECLAIMABLE_STORAGE_HPP
+
+//EOF

Modified: sandbox/monotonic/boost/monotonic/shared_allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_allocator.hpp (original)
+++ sandbox/monotonic/boost/monotonic/shared_allocator.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -30,13 +30,13 @@
                 struct shared_allocator : allocator<T, Region, shared_access_tag>
                 {
                         typedef allocator<T, Region, shared_access_tag> Parent;
- using typename Parent::size_type;
- using typename Parent::difference_type;
- using typename Parent::pointer;
- using typename Parent::const_pointer;
- using typename Parent::reference;
- using typename Parent::const_reference;
- using typename Parent::value_type;
+ using BOOST_DEDUCED_TYPENAME Parent::size_type;
+ using BOOST_DEDUCED_TYPENAME Parent::difference_type;
+ using BOOST_DEDUCED_TYPENAME Parent::pointer;
+ using BOOST_DEDUCED_TYPENAME Parent::const_pointer;
+ using BOOST_DEDUCED_TYPENAME Parent::reference;
+ using BOOST_DEDUCED_TYPENAME Parent::const_reference;
+ using BOOST_DEDUCED_TYPENAME Parent::value_type;
 
                         template <class U>
                         struct rebind

Modified: sandbox/monotonic/boost/monotonic/shared_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/shared_storage.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -16,8 +16,8 @@
         {
                 namespace detail
                 {
- template <>
- struct storage_type<shared_access_tag>
+ template <class Region>
+ struct storage_type<Region,shared_access_tag>
                         {
                                 template <size_t N, size_t M, class Al>
                                 struct storage

Modified: sandbox/monotonic/boost/monotonic/static_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/static_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/static_storage.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -14,8 +14,8 @@
         {
                 namespace detail
                 {
- template <>
- struct storage_type<default_access_tag>
+ template <class Region>
+ struct storage_type<Region, default_access_tag>
                         {
                                 template <size_t N, size_t M, class Al>
                                 struct storage
@@ -33,8 +33,8 @@
                 struct static_storage
                 {
                         typedef Al HeapAllocator;
- typedef detail::storage_type<Access> Selector;
- typedef typename Selector::template storage<InlineSize, MinHeapIncrement, HeapAllocator>::type StorageType;
+ typedef detail::storage_type<Region,Access> Selector;
+ typedef BOOST_DEDUCED_TYPENAME Selector::template storage<InlineSize, MinHeapIncrement, HeapAllocator>::type StorageType;
 
                 private:
                         static StorageType global;
@@ -79,7 +79,7 @@
                         , size_t InlineSize
                         , size_t MinHeapIncrement
                         , class Al>
- typename static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::StorageType
+ BOOST_DEDUCED_TYPENAME static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::StorageType
                         static_storage<Region, Access, InlineSize, MinHeapIncrement, Al>::global;
 
                 //template <class Region

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -30,7 +30,7 @@
 
                         typedef storage<InlineSize, MinHeapIncrement, Al> This;
                         typedef Al Allocator;
- typedef typename Allocator::template rebind<char>::other CharAllocator;
+ typedef BOOST_DEDUCED_TYPENAME Allocator::template rebind<char>::other CharAllocator;
                         typedef detail::Link<CharAllocator> Link;
                         typedef detail::Pool Pool;
                         typedef std::vector<Link> Chain;
@@ -133,6 +133,11 @@
                                 return ptr;
                         }
 
+ void deallocate(void *ptr)
+ {
+ // do nothing
+ }
+
                         size_t max_size() const
                         {
                                 return (std::numeric_limits<size_t>::max)();

Modified: sandbox/monotonic/boost/monotonic/storage_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage_base.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -23,6 +23,8 @@
 
                         // the number of bytes to allocate, and the alignment to use
                         virtual void *allocate(size_t num_bytes, size_t alignment) = 0;
+
+ virtual void deallocate(void * ptr) = 0;
                         
                         virtual size_t max_size() const = 0;
                         

Modified: sandbox/monotonic/boost/monotonic/thread_local_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/thread_local_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/thread_local_storage.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -16,8 +16,8 @@
         {
                 namespace detail
                 {
- template <>
- struct storage_type<thread_local_access_tag>
+ template <class Region>
+ struct storage_type<Region, thread_local_access_tag>
                         {
                                 template <size_t N, size_t M, class Al>
                                 struct storage

Modified: sandbox/monotonic/boost/utility/iter_range.hpp
==============================================================================
--- sandbox/monotonic/boost/utility/iter_range.hpp (original)
+++ sandbox/monotonic/boost/utility/iter_range.hpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -66,12 +66,12 @@
         }
 
         template <class C>
- struct iter_range : iter_range_detail::iter_range<typename C::iterator>
+ struct iter_range : iter_range_detail::iter_range<BOOST_DEDUCED_TYPENAME C::iterator>
         {
                 typedef C Container;
- typedef typename Container::iterator iterator;
+ typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator;
                 typedef iter_range_detail::iter_range<iterator> Parent;
- typedef typename boost::iterator_value<iterator>::type Value;
+ typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<iterator>::type Value;
                 using Parent::first;
                 using Parent::second;
 
@@ -100,12 +100,12 @@
         };
 
         template <class C>
- struct const_iter_range : iter_range_detail::iter_range<typename C::const_iterator>
+ struct const_iter_range : iter_range_detail::iter_range<BOOST_DEDUCED_TYPENAME C::const_iterator>
         {
                 typedef C Container;
- typedef typename Container::const_iterator const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME Container::const_iterator const_iterator;
                 typedef iter_range_detail::iter_range<const_iterator> Parent;
- typedef typename boost::iterator_value<const_iterator>::type Value;
+ typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<const_iterator>::type Value;
                 using Parent::first;
                 using Parent::second;
 

Modified: sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -10,6 +10,8 @@
 #include <boost/monotonic/shared_allocator.hpp>
 #include <boost/monotonic/local.hpp>
 #include <boost/monotonic/allocator.hpp>
+#include <boost/interprocess/containers/list.hpp>
+#include <boost/monotonic/reclaimable_storage.hpp>
 
 #define BOOST_TEST_MODULE basic_test test
 #include <boost/test/unit_test.hpp>
@@ -22,10 +24,47 @@
 #pragma warning(disable:4996)
 #endif
 
+using monotonic::heap_region_tag;
+
+BOOST_AUTO_TEST_CASE(test_reclaimable)
+{
+ std::list<int, monotonic::allocator<int, heap_region_tag> > list;
+ monotonic::storage_base *store = &monotonic::static_storage<heap_region_tag>::get_storage();
+ list.push_back(42);
+ size_t used_before = monotonic::static_storage<heap_region_tag>::used();
+ list.erase(list.begin());
+ size_t used_after = monotonic::static_storage<heap_region_tag>::used();
+ BOOST_ASSERT(used_after < used_before);
+}
+
+BOOST_AUTO_TEST_CASE(test_interprocess_list)
+{
+ monotonic::storage<> storage;
+ {
+ interprocess::list<int, monotonic::allocator<int> > list(storage);
+ generate_n(back_inserter(list), 10, rand);
+ list.sort();
+ }
+}
+
 // define some private regions
 struct region0 {};
 struct region1 {};
 
+BOOST_AUTO_TEST_CASE(test_set)
+{
+
+ monotonic::storage<> storage;
+ {
+ monotonic::set<monotonic::vector<int> > set(storage);
+ BOOST_ASSERT(set.get_allocator().get_storage() == &storage);
+ set.insert(monotonic::vector<int>(storage));
+ monotonic::vector<int> &v = *set.begin();
+ BOOST_ASSERT(v.get_allocator().get_storage() == &storage);
+
+ }
+}
+
 BOOST_AUTO_TEST_CASE(test_string)
 {
         monotonic::string<> str1;
@@ -95,6 +134,7 @@
         monotonic::static_storage<>::reset();
         monotonic::static_storage<region1>::reset();
 
+
         monotonic::storage<> storage;
         {
                 monotonic::vector<monotonic::vector<int> > vec(storage);

Modified: sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -168,13 +168,13 @@
 
 
 template <class II>
-typename boost::iterator_value<II>::type calc_mean(II first, II last, size_t num)
+BOOST_DEDUCED_TYPENAME boost::iterator_value<II>::type calc_mean(II first, II last, size_t num)
 {
- return std::accumulate(first, last, typename boost::iterator_value<II>::type(0))*(1.0/num);
+ return std::accumulate(first, last, BOOST_DEDUCED_TYPENAME boost::iterator_value<II>::type(0))*(1.0/num);
 }
 
 template <class II>
-typename boost::iterator_value<II>::type calc_mean(II first, II last)
+BOOST_DEDUCED_TYPENAME boost::iterator_value<II>::type calc_mean(II first, II last)
 {
         if (first == last)
                 throw std::range_error("calc_mean");
@@ -182,9 +182,9 @@
 }
 
 template <class II>
-std::pair<typename boost::iterator_value<II>::type,typename boost::iterator_value<II>::type> standard_deviation_mean(II first, II last)
+std::pair<BOOST_DEDUCED_TYPENAME boost::iterator_value<II>::type,BOOST_DEDUCED_TYPENAME boost::iterator_value<II>::type> standard_deviation_mean(II first, II last)
 {
- typedef typename boost::iterator_value<II>::type Value;
+ typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<II>::type Value;
         size_t length = std::distance(first, last);
         if (length == 0)
                 throw std::range_error("standard_deviation_mean");
@@ -200,7 +200,7 @@
 }
 
 template <class Cont>
-std::pair<typename Cont::value_type, typename Cont::value_type> standard_deviation_mean(Cont const &cont)
+std::pair<BOOST_DEDUCED_TYPENAME Cont::value_type, BOOST_DEDUCED_TYPENAME Cont::value_type> standard_deviation_mean(Cont const &cont)
 {
         return standard_deviation_mean(cont.begin(), cont.end());
 }
@@ -341,8 +341,8 @@
 {
         if (count == 0)
                 return;
- typedef typename Storage::template allocator<int>::type allocator;
- typedef typename Storage::template allocator<char>::type char_allocator;
+ typedef BOOST_DEDUCED_TYPENAME Storage::template allocator<int>::type allocator;
+ typedef BOOST_DEDUCED_TYPENAME Storage::template allocator<char>::type char_allocator;
         std::list<int, allocator > list;
         fill_n(back_inserter(list), 100, 42);
         typedef std::basic_string<char, std::char_traits<char>, char_allocator> String;

Modified: sandbox/monotonic/libs/monotonic/test/monotonic.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/monotonic.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/monotonic.vcproj 2009-06-24 00:32:28 EDT (Wed, 24 Jun 2009)
@@ -291,6 +291,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\boost\monotonic\reclaimable_storage.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\boost\monotonic\shared_allocator.hpp"
>
                                 </File>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk