Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53959 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-15 23:07:34


Author: cschladetsch
Date: 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
New Revision: 53959
URL: http://svn.boost.org/trac/boost/changeset/53959

Log:
renamed storage to fixed_storage and chained_storage to storage
Text files modified:
   sandbox/monotonic/boost/monotonic/chained_storage.h | 32 +++++++++++++++++---------------
   sandbox/monotonic/boost/monotonic/storage.h | 4 ++--
   sandbox/monotonic/libs/monotonic/test/main.cpp | 40 ++++++----------------------------------
   sandbox/monotonic/libs/monotonic/test/rope.cpp | 4 ++--
   sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp | 2 +-
   sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp | 2 +-
   sandbox/monotonic/libs/monotonic/test/test_map_list.cpp | 10 ----------
   7 files changed, 29 insertions(+), 65 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/chained_storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/chained_storage.h (original)
+++ sandbox/monotonic/boost/monotonic/chained_storage.h 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -14,12 +14,12 @@
         {
                 /// storage that spans the stack/heap boundary.
                 ///
- /// allocation requests first use inline storage of N bytes.
+ /// allocation requests first use inline fixed_storage of N bytes.
                 /// once that is exhausted, later requests are serviced from the heap.
                 ///
                 /// all allocations remain valid at all times.
- template <size_t N, size_t MinLinkSize = N*1000, class Al = std::allocator<char> >
- struct chained_storage : storage_base
+ template <size_t InlineSize = 8*1024, size_t MinHeapSize = InlineSize*1000, class Al = std::allocator<char> >
+ struct storage : storage_base
                 {
                         typedef Al Allocator;
                         typedef typename Allocator::template rebind<char>::other CharAllocator;
@@ -51,6 +51,10 @@
                                 {
                                     cursor = 0;
                                 }
+ size_t used() const
+ {
+ return cursor;
+ }
                                 bool CanAllocate(size_t num_bytes) const
                                 {
                                         return capacity - cursor >= num_bytes;
@@ -71,18 +75,16 @@
                         typedef std::vector<Link, Al> Chain;
 
                 private:
- storage<N> fixed; // the inline storage
- Chain chain; // heap-based storage
- Allocator alloc; // allocator for heap-based storage
- size_t next_link;
+ fixed_storage<InlineSize> fixed; // the inline fixed_storage
+ Chain chain; // heap-based fixed_storage
+ Allocator alloc; // allocator for heap-based fixed_storage
 
                 public:
- chained_storage()
- : next_link(0)
+ storage()
                         {
                         }
- chained_storage(Allocator const &A)
- : alloc(A), next_link(0)
+ storage(Allocator const &A)
+ : alloc(A)
                         {
                         }
 
@@ -108,7 +110,7 @@
                                                 return ptr;
                                         }
                                 }
- size_t size = std::max(MinLinkSize, num_bytes*2);
+ size_t size = std::max(MinHeapSize, num_bytes*2);
                                 return AddLink(size).Allocate(num_bytes, alignment);
                         }
 
@@ -119,7 +121,7 @@
 
                         size_t max_size() const
                         {
- return std::numeric_limits<size_t>::max(); //??
+ return std::numeric_limits<size_t>::max();
                         }
 
                         size_t fixed_remaining() const
@@ -129,14 +131,14 @@
 
                         size_t remaining() const
                         {
- return max_size(); //??!!
+ return max_size();
                         }
 
                         size_t used() const
                         {
                                 size_t count = fixed.used();
                                 BOOST_FOREACH(Link const &link, chain)
- count += link.used;
+ count += link.used();
                                 return count;
                         }
 

Modified: sandbox/monotonic/boost/monotonic/storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.h (original)
+++ sandbox/monotonic/boost/monotonic/storage.h 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -24,7 +24,7 @@
         {
                 /// storage for an allocator that is on the stack or heap
                 template <size_t N>
- struct storage : storage_base
+ struct fixed_storage : storage_base
                 {
 
 #ifdef BOOST_MONOTONIC_USE_AUTOBUFFER
@@ -40,7 +40,7 @@
                         size_t num_allocations;
 #endif
                 public:
- storage()
+ fixed_storage()
                                 : cursor(0)
 #ifndef NDEBUG
                                 , num_allocations(0)

Modified: sandbox/monotonic/libs/monotonic/test/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/main.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/main.cpp 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -41,7 +41,7 @@
 
 void test_deque()
 {
- monotonic::storage<4000> storage; // create local storage on the stack
+ monotonic::storage<4000> storage;
         {
                 {
                         std::list<int, boost::monotonic::allocator<int> > list(storage);
@@ -81,8 +81,8 @@
 
 void test_basic()
 {
- monotonic::storage<1000*sizeof(int)> storage1; // create local storage on the stack
- monotonic::vector<int> v1(storage1); // create a vector that uses this storage
+ monotonic::storage<1000*sizeof(int)> storage1;
+ monotonic::vector<int> v1(storage1);
 
         for(int i = 0; i < 100; ++i)
                 v1.push_back(i);
@@ -203,7 +203,7 @@
         size_t num_iterations = 100000;
 
         typedef monotonic::map<int, monotonic::list<int> > map_with_list;
- monotonic::storage<10000000> *storage = new monotonic::storage<10000000>;
+ monotonic::storage<1000000> *storage = new monotonic::storage<1000000>;
 
         // do the test with monotonic containers and heap-based storage
         {
@@ -242,35 +242,8 @@
         }
 }
 
-// #define BOOST_MONOTONIC_USE_AUTOBUFFER before including <boost/monotonic/storage.h> to
-// try this at home.
-void test_auto_buffer()
-{
- monotonic::storage<10> storage;
-
- // this fails because the storage that the vector uses
- // will be moved when the buffer resizes...
- //monotonic::vector<int> vec(storage);
- //for (size_t n = 0; n < 100; ++n)
- //{
- // vec.push_back(n);
- //}
-
- // this fails because at the end of the buffer, just before
- // it may be resized and possibly put onto heap, the following asserts
- // on MSVC in <xtree>:
- // if (max_size() - 1 <= _Mysize)
- // _THROW(length_error, "map/set<T> too long");
- //
- //monotonic::map<int, int> map(storage);
- //for (int n = 0; n < 100; ++n)
- // map[n] = n;
-}
-
-
 namespace
 {
-
         template<typename C>
         struct Foo
         {
@@ -284,7 +257,7 @@
         template<typename C>
         void test_loop_monotonic()
         {
- boost::monotonic::storage<100000> storage;
+ boost::monotonic::fixed_storage<100000> storage;
                 boost::monotonic::vector<Foo<C> > vec(storage);
                 Foo<C> orig = { 'A', 65 };
                 vec.assign(ELEM_COUNT, orig);
@@ -312,7 +285,7 @@
 
 void test_alignment()
 {
- monotonic::storage<10000> storage;
+ monotonic::fixed_storage<10000> storage;
 
         // the two arguments to storage.allocate are the size, and the required alignment
         void *P = storage.allocate(3, 4);
@@ -436,7 +409,6 @@
         //test_chain();
         test_shared_allocators();
         test_alignment();
- test_auto_buffer();
         test_speed();
         test_speed_heap();
         test_basic();

Modified: sandbox/monotonic/libs/monotonic/test/rope.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/rope.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/rope.cpp 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -47,7 +47,7 @@
 void test_rope()
 {
         {
- monotonic::storage<4000> storage; // create local storage on the stack
+ monotonic::fixed_storage<4000> storage; // create local storage on the stack
                 {
                         monotonic::chain<int, 100> rope(storage);
                         for (int n = 0; n < 200; ++n)
@@ -58,7 +58,7 @@
         }
 
 
- monotonic::storage<1000> storage;
+ monotonic::fixed_storage<1000> storage;
         {
                 typedef monotonic::chain<Foo, 2> Rope2;
                 Rope2 foo(4, storage);

Modified: sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -26,7 +26,7 @@
 
 pair<double,double> test_bubble_sort(size_t count = 50*1000, size_t length = 20)
 {
- monotonic::storage<100000> storage;// = new monotonic::storage<100000>();
+ monotonic::fixed_storage<100000> storage;// = new monotonic::storage<100000>();
         boost::timer mono_timer;
         for (size_t n = 0; n < count; ++n)
         {

Modified: sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -3,7 +3,7 @@
 
 void test_chained_storage()
 {
- monotonic::chained_storage<10> store;
+ monotonic::storage<10> store;
         {
                 typedef std::vector<char, monotonic::allocator<char> > Vector;
                 Vector vec(store);

Modified: sandbox/monotonic/libs/monotonic/test/test_map_list.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_map_list.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/test_map_list.cpp 2009-06-15 23:07:33 EDT (Mon, 15 Jun 2009)
@@ -55,16 +55,6 @@
         typedef std::map<size_t, pair<double, double> > Results;
         Results results;
 
- // do a test with a large dataset on the heap
- if (0)
- {
- const size_t buffer_size = 10*1000*1000;
- monotonic::storage<buffer_size> *storage = new monotonic::storage<buffer_size>;
- size_t num_loops = 100*1000;
- results[num_loops] = test_map_list(outter_loops, num_loops, *storage);
- delete storage;
- }
-
         for (size_t inner = 100; inner < inner_loops; inner += 1000)
         {
                 results[inner] = test_map_list(outter_loops, inner, storage);


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