Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54263 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-23 01:35:28


Author: cschladetsch
Date: 2009-06-23 01:35:26 EDT (Tue, 23 Jun 2009)
New Revision: 54263
URL: http://svn.boost.org/trac/boost/changeset/54263

Log:
added test for local storage

Text files modified:
   sandbox/monotonic/boost/monotonic/config.hpp | 6 ++++--
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp | 13 +++++++------
   sandbox/monotonic/boost/monotonic/local.hpp | 2 +-
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 15 ++++-----------
   4 files changed, 16 insertions(+), 20 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/config.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/config.hpp (original)
+++ sandbox/monotonic/boost/monotonic/config.hpp 2009-06-23 01:35:26 EDT (Tue, 23 Jun 2009)
@@ -12,14 +12,16 @@
 {
         namespace monotonic
         {
+ typedef std::allocator<char> default_allocator;
+
                 struct DefaultSizes
                 {
                         enum
                         {
                                 InlineSize = 32*1024, ///< buffer that is inline with the storage
                                 MinHeapIncrement = 32*1024*1024, ///< the smallest new chunk-size for heap storage
- StaticInlineSize = 1*1024*1024, ///< inline size for a global store. this goes into your BSS
- StaticMinHeapIncrement = 32*1024*1024,
+ //StaticInlineSize = 1*1024*1024, ///< inline size for a global store. this goes into your BSS
+ //StaticMinHeapIncrement = 32*1024*1024,
                                 MinPoolSize = 8,
 
                                 RegionInlineSize = 8*1024,

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-23 01:35:26 EDT (Tue, 23 Jun 2009)
@@ -16,6 +16,7 @@
 {
         namespace monotonic
         {
+
                 /// fixed-sized storage for an allocator that is on the stack or heap
                 template <size_t InlineSize = DefaultSizes::InlineSize>
                 struct fixed_storage;
@@ -29,7 +30,7 @@
                 template <
                         size_t InlineSize = DefaultSizes::InlineSize
                         , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
- , class Al = std::allocator<char> >
+ , class Al = default_allocator >
                 struct storage;
 
                 /// tags for different storage regions
@@ -59,21 +60,21 @@
                 /// thread-safe storage
                 template <size_t InlineSize = DefaultSizes::InlineSize
                         , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
- , class Al = std::allocator<char> >
+ , class Al = default_allocator>
                 struct shared_storage;
 
                 /// thread-local storage
                 template <size_t InlineSize = DefaultSizes::InlineSize
                         , size_t MinHeapIncrement = DefaultSizes::MinHeapIncrement
- , class Al = std::allocator<char> >
+ , class Al = default_allocator >
                 struct thread_local_storage;
 
                 /// a globally available storage buffer
                 template <class Region = default_region_tag
                         , class Access = default_access_tag
- , size_t InlineSize = DefaultSizes::StaticInlineSize
- , size_t MinHeapIncrement = DefaultSizes::StaticMinHeapIncrement
- , class Al = std::allocator<char> >
+ , size_t InlineSize = DefaultSizes::/*Static*/InlineSize
+ , size_t MinHeapIncrement = DefaultSizes::/*Static*/MinHeapIncrement
+ , class Al = default_allocator >
                 struct static_storage;
 
                 /// common to other monotonic allocators for type T of type Derived

Modified: sandbox/monotonic/boost/monotonic/local.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/local.hpp (original)
+++ sandbox/monotonic/boost/monotonic/local.hpp 2009-06-23 01:35:26 EDT (Tue, 23 Jun 2009)
@@ -21,7 +21,7 @@
                                 , Access
                                 , DefaultSizes::InlineSize
                                 , DefaultSizes::MinHeapIncrement
- , std::allocator<void> > StaticStorage;
+ , default_allocator > StaticStorage;
 
                         local()
                         {

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-23 01:35:26 EDT (Tue, 23 Jun 2009)
@@ -275,22 +275,15 @@
         monotonic::local<local_1> storage;
         {
                 std::list<int, monotonic::allocator<int, local_1> > list;
+ BOOST_ASSERT(list.get_allocator().get_storage() == &storage.get_storage());
                 list.push_back(42);
                 string &s = storage.create<string>("foo");
-
                 cout << "test_locals: size=" << storage.get_storage().used() << endl;
- storage.destroy(s);
- storage.destroy(list);
- storage.reset();
- cout << "test_locals: size=" << storage.get_storage().used() << endl;
-
                 std::vector<int, monotonic::allocator<int, local_1> > vec;
+ BOOST_ASSERT(vec.get_allocator().get_storage() == &storage.get_storage());
                 vec.resize(100);
                 cout << "test_locals: size=" << storage.get_storage().used() << endl;
- storage.destroy(vec);
- storage.reset();
- cout << "test_locals: size=" << storage.get_storage().used() << endl;
-
+ storage.destroy(s);
         }
 }
 
@@ -366,7 +359,7 @@
                 cout << "results of running test at:" << endl;
                 cout << "https://svn.boost.org/svn/boost/sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp" << endl << endl;
 
- //test_locals();
+ test_locals();
                 //test_pools();
                 //return 0;
 


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