Boost logo

Boost-Commit :

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


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

Log:
added local<>::allocator<T>::type
Text files modified:
   sandbox/monotonic/boost/monotonic/local.hpp | 8 ++++++++
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 33 +++++++++++++++++++++------------
   2 files changed, 29 insertions(+), 12 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/local.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/local.hpp (original)
+++ sandbox/monotonic/boost/monotonic/local.hpp 2009-06-23 01:46:31 EDT (Tue, 23 Jun 2009)
@@ -16,6 +16,8 @@
                 template <class Region, class Access>
                 struct local
                 {
+ typedef local<Region,Access> This;
+
                         typedef static_storage<
                                 Region
                                 , Access
@@ -23,6 +25,12 @@
                                 , DefaultSizes::MinHeapIncrement
                                 , default_allocator > StaticStorage;
 
+ template <class T>
+ struct allocator
+ {
+ typedef monotonic::allocator<T, Region, Access> type;
+ };
+
                         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:46:31 EDT (Tue, 23 Jun 2009)
@@ -270,21 +270,30 @@
 
 struct local_1 {};
 
+template <class Storage>
+void test_locals(Storage &storage)
+{
+ typedef typename Storage::allocator<int>::type allocator;
+
+ std::list<int, allocator > list;
+ monotonic::storage_base *b0 = list.get_allocator().get_storage();
+ monotonic::storage_base *b1 = &storage.get_storage();
+
+ BOOST_ASSERT(list.get_allocator().get_storage() == &storage.get_storage());
+ list.push_back(42);
+ string &s = storage.create<string>("foo");
+ std::vector<int, allocator > vec;
+ BOOST_ASSERT(vec.get_allocator().get_storage() == &storage.get_storage());
+ vec.resize(100);
+ cout << "test_locals: stack,heap =" << storage.get_storage().fixed_used() << ", " << storage.get_storage().heap_used() << endl;
+ storage.destroy(s);
+}
+
 void test_locals()
 {
         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;
- 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(s);
- }
+ for (size_t n = 0; n < 10; ++n)
+ test_locals(storage);
 }
 
 void test_pools()


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