Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54179 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-22 01:41:39


Author: cschladetsch
Date: 2009-06-22 01:41:39 EDT (Mon, 22 Jun 2009)
New Revision: 54179
URL: http://svn.boost.org/trac/boost/changeset/54179

Log:
added "mini-heap" functionality for storage

Text files modified:
   sandbox/monotonic/boost/monotonic/storage.hpp | 14 ++++++++++++--
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 7 +++++--
   2 files changed, 17 insertions(+), 4 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-06-22 01:41:39 EDT (Mon, 22 Jun 2009)
@@ -146,14 +146,24 @@
                                 return max_size();
                         }
 
- size_t used() const
+ size_t fixed_used() const
+ {
+ return fixed.used();
+ }
+
+ size_t heap_used() const
                         {
- size_t count = fixed.used();
+ size_t count = 0;
                                 BOOST_FOREACH(Link const &link, chain)
                                         count += link.used();
                                 return count;
                         }
 
+ size_t used() const
+ {
+ return fixed_used() + heap_used();
+ }
+
                         size_t num_links() const
                         {
                                 return chain.size();

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-22 01:41:39 EDT (Mon, 22 Jun 2009)
@@ -439,8 +439,9 @@
         }
 
         {
- // storage starts on the stack, then merges into the heap as needed
- monotonic::storage<> storage;
+ length = 4;
+ // storage starts on the stack (in this case, 10k of it), then merges into the heap as needed
+ monotonic::storage<10*1024> storage;
                 for (size_t n = 0; n < length; ++n)
                 {
                         // create a new int from storage
@@ -467,6 +468,8 @@
 
                         // destroy objects. this only calls the destructors; it does not release memory
                         storage.destroy(s1);
+
+ cout << "storage.fixed, heap, total used: " << storage.fixed_used() << ", " << storage.heap_used() << ", " << storage.used() << endl;
                 }
                 // storage is released. if this was only ever on the stack, no work is done
         }


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