$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54049 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-18 02:50:49
Author: cschladetsch
Date: 2009-06-18 02:50:46 EDT (Thu, 18 Jun 2009)
New Revision: 54049
URL: http://svn.boost.org/trac/boost/changeset/54049
Log:
added local<>, removed ability for containers to be constructed from storage<>
Added:
   sandbox/monotonic/boost/monotonic/local.hpp   (contents, props changed)
Properties modified: 
   sandbox/monotonic/libs/monotonic/test/   (props changed)
Text files modified: 
   sandbox/monotonic/boost/monotonic/allocator.hpp                |     8 +                                       
   sandbox/monotonic/boost/monotonic/allocator_base.hpp           |     6                                         
   sandbox/monotonic/boost/monotonic/config.hpp                   |     4                                         
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp     |     3                                         
   sandbox/monotonic/boost/monotonic/shared_allocator.hpp         |     4                                         
   sandbox/monotonic/boost/monotonic/static_storage.hpp           |    22 +++++                                   
   sandbox/monotonic/boost/monotonic/storage.hpp                  |     1                                         
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp  |   134 ++++++++++++++++++++++++----------      
   sandbox/monotonic/libs/monotonic/test/main.cpp                 |   154 +++++++++++++++------------------------ 
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj         |    22 +++++                                   
   sandbox/monotonic/libs/monotonic/test/rope.cpp                 |    10 +-                                      
   sandbox/monotonic/libs/monotonic/test/test_bubble_sort.cpp     |     4                                         
   sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp |     4                                         
   sandbox/monotonic/libs/monotonic/test/test_dupe.cpp            |     4                                         
   sandbox/monotonic/libs/monotonic/test/test_map_list.cpp        |    10 +-                                      
   15 files changed, 231 insertions(+), 159 deletions(-)
Modified: sandbox/monotonic/boost/monotonic/allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator.hpp	(original)
+++ sandbox/monotonic/boost/monotonic/allocator.hpp	2009-06-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -26,6 +26,9 @@
                         };
                 };
 
+		storage_base &get_storage();
+		storage_base *set_storage(storage_base &);
+
                 template <class T> 
                 struct allocator : allocator_base<T, allocator<T> >
                 {
@@ -45,11 +48,14 @@
                         };
 
                         allocator() throw() 
-				: Parent(static_storage) { }
+				: Parent(boost::monotonic::get_storage()) { }
 
+		private:
+			template <class T> struct local;
                         allocator(storage_base &store) throw() 
                                 : Parent(store) { }
 
+		public:
                         allocator(const allocator& alloc) throw() 
                                 : Parent(alloc) { }
 
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -66,7 +66,7 @@
                                 template <class Storage>
                                 static T Given(Storage &storage)
                                 {
-					return T(storage);
+					return T();//storage);
                                 }
                         };
                 }
@@ -130,12 +130,12 @@
 
                         void construct(pointer ptr)
                         {
-				detail::Construct<detail::is_monotonic<T>::value>::Given(ptr, static_cast<Derived *>(this));
+				new (ptr) T();//detail::Construct<detail::is_monotonic<T>::value>::Given(ptr, static_cast<Derived *>(this));
                         }
 
                         void construct(pointer ptr, const T& val)
                         {
-				detail::Construct<detail::is_monotonic<T>::value>::Given(ptr, val, static_cast<Derived *>(this));
+				new (ptr) T(val);//detail::Construct<detail::is_monotonic<T>::value>::Given(ptr, val, static_cast<Derived *>(this));
                         }
 
                         void destroy(pointer ptr)
Modified: sandbox/monotonic/boost/monotonic/config.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/config.hpp	(original)
+++ sandbox/monotonic/boost/monotonic/config.hpp	2009-06-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -15,9 +15,9 @@
                         enum
                         {
                                 InlineSize = 8*1024,						///< buffer that is inline with the storage
-				MinHeapIncrement = 64*1024*1024,			///< the smallest new chunk-size for heap storage
+				MinHeapIncrement = 4*1024*1024,				///< the smallest new chunk-size for heap storage
                                 StaticInlineSize = 64*1024,					///< inline size for a global store. this goes into your BSS
-				StaticMinHeapIncrement = 64*1024*1024,
+				StaticMinHeapIncrement = 4*1024*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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -32,6 +32,9 @@
                         , class Al = std::allocator<char> >
                 struct storage;
 
+		template <class Storage = storage<> >
+		struct local;
+
                 /// thread-safe storage
                 template <
                         size_t InlineSize = DefaultSizes::InlineSize
Added: sandbox/monotonic/boost/monotonic/local.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/local.hpp	2009-06-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -0,0 +1,79 @@
+// 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_LOCAL_HPP
+#define BOOST_MONOTONIC_LOCAL_HPP
+
+#include <boost/monotonic/storage.hpp>
+
+namespace boost
+{
+	namespace monotonic
+	{
+		template <class Storage>
+		struct local : storage_base
+		{
+
+		private:
+			Storage store;
+			storage_base *old;
+
+		public:
+			local()
+			{
+				old = set_storage(store);
+			}
+			~local()
+			{
+				if (old)
+					set_storage(*old);
+				else
+					default_storage();
+			}
+
+			void reset()
+			{
+				store.reset();
+			}
+			void release()
+			{
+				store.release();
+			}
+
+			template <class T>
+			allocator<T> make_allocator()
+			{
+				return allocator<T>(store);
+			}
+
+			// the number of bytes to allocate, and the alignment to use
+			void *allocate(size_t num_bytes, size_t alignment)
+			{
+				return store.allocate(num_bytes, alignment);
+			}
+
+			size_t max_size() const
+			{
+				return store.max_size();
+			}
+
+			size_t used() const
+			{
+				return store.used();
+			}
+
+			size_t remaining() const
+			{
+				return store.remaining();
+			}
+		};
+
+	} // namespace monotonic
+
+} // namespace boost
+
+#endif // BOOST_MONOTONIC_LOCAL_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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -50,8 +50,8 @@
                         shared_allocator() throw() 
                                 : Parent(static_shared_storage)	{ }
 
-			shared_allocator(shared_storage_base &store) throw() 
-				: Parent(store) { }
+			//shared_allocator(shared_storage_base &store) throw() 
+			//	: Parent(store) { }
 
                         shared_allocator(const shared_allocator& alloc) throw() 
                                 : Parent(alloc) { }
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -56,7 +56,27 @@
                 };
 
                 /// 'static_storage' will be used by a default-constructed monotonic::allocator
-		extern static_storage_base<> static_storage;
+		extern static_storage_base<> default_static_storage;
+		extern storage_base *static_storage;
+
+		inline storage_base &get_storage()
+		{
+			return static_storage ? *static_storage : default_static_storage;
+		}
+		inline storage_base *set_storage(storage_base &store)
+		{
+			storage_base *old = static_storage;
+			static_storage = &store;
+			return old;
+		}
+		inline void reset_storage()
+		{
+			get_storage().reset();
+		}
+		inline void default_storage()
+		{
+			static_storage = &default_static_storage;
+		}
                 
                 /// TODO: this will be specialised for 
                 /// static_storage_base<..., shared_storage>, but to avoid having to link against boost::thread
Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp	(original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp	2009-06-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -172,6 +172,7 @@
                         }
                 };
 
+
         } // namespace monotonic
 
 } // namespace boost
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -2,37 +2,55 @@
 #include <boost/pool/pool.hpp>
 #include <boost/pool/pool_alloc.hpp>
 
-template <class Pool>
-int thrash_pool(size_t length, Pool &pool)
+struct thrash_pool
 {
-	generate_n(back_inserter(pool), length, rand);
-	int total = 0;
-	BOOST_FOREACH(int n, pool)
+	template <class Pool>
+	void operator()(size_t length, Pool &pool) const
         {
-		total += n;
+		fill_n(back_inserter(pool), length, 42);
         }
-	return total;
-}
+};
+
+struct thrash_pool_sort
+{
+	template <class Pool>
+	int operator()(size_t length, Pool &pool) const
+	{
+		srand(42);
+		generate_n(back_inserter(pool), length, rand);
+		pool.sort();
+		int total = 0;
+		BOOST_FOREACH(int n, pool)
+		{
+			total += n;
+		}
+		return total;
+	}
+};
 
 struct PoolResult 
 {
         double pool_elapsed;
         double fast_pool_elapsed;
         double mono_elapsed;
+	double local_mono_elapsed;
         double std_elapsed;
+	PoolResult()
+	{
+		pool_elapsed = fast_pool_elapsed = mono_elapsed = local_mono_elapsed = std_elapsed = 0;
+	}
 };
 
-PoolResult compare_memory_pool(size_t count, size_t length)
+template <class Fun>
+PoolResult compare_memory_pool(size_t count, size_t length, Fun fun)
 {
-	typedef boost::fast_pool_allocator<int,
+	cout << "compare_memory_pool: " << count << ", " << length << endl;
+	typedef std::list<int, boost::pool_allocator<int,
                 boost::default_user_allocator_new_delete,
-		boost::details::pool::null_mutex> fast_pool_alloc;
-	typedef boost::pool_allocator<int,
+		boost::details::pool::null_mutex> > pool_v;
+	typedef std::list<int, boost::fast_pool_allocator<int,
                 boost::default_user_allocator_new_delete,
-		boost::details::pool::null_mutex> pool_alloc;
-
-	typedef std::list<int, pool_alloc > pool_v;
-	typedef std::list<int, fast_pool_alloc > fast_pool_v;
+		boost::details::pool::null_mutex> > fast_pool_v;
         typedef std::list<int, boost::monotonic::allocator<int> > mono_v;
         typedef std::list<int > std_v;
 
@@ -43,28 +61,34 @@
                 boost::timer timer;
                 for (size_t n = 0; n < count; ++n)
                 {
+			srand(42);
                         {
                                 fast_pool_v pool;
-				thrash_pool(length, pool);
+				fun(length, pool);
                         }
                         boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(int)>::release_memory();
                 }
                 result.fast_pool_elapsed = timer.elapsed();
         }
 
-	// test boost::pool_allocator
+	// test boost::pool_allocator. dont bother for larger sizes as it is known to be slow
+	if (length < 3000)
         {
                 boost::timer timer;
                 for (size_t n = 0; n < count; ++n)
                 {
                         {
                                 pool_v pool;
-				thrash_pool(length, pool);
+				fun(length, pool);
                         }
                         boost::singleton_pool<boost::pool_allocator_tag, sizeof(int)>::release_memory();
                 }
                 result.pool_elapsed = timer.elapsed();
         }
+	else
+	{
+		result.pool_elapsed = -1;
+	}
 
         // test monotonic
         {
@@ -73,52 +97,84 @@
                 {
                         {
                                 mono_v pool;
-				thrash_pool(length, pool);
+				fun(length, pool);
                         }
-			monotonic::static_storage.reset();
+			boost::monotonic::get_storage().reset();
                 }
                 result.mono_elapsed = timer.elapsed();
         }
 
+
+	// test local monotonic
+	{
+		monotonic::local<monotonic::storage<100000> > storage;
+		boost::timer timer;
+		for (size_t n = 0; n < count; ++n)
+		{
+			{
+				mono_v pool;
+				fun(length, pool);
+			}
+			storage.reset();
+		}
+		result.local_mono_elapsed = timer.elapsed();
+	}
+
         // test std
+	if (0)
         {
                 boost::timer timer;
                 for (size_t n = 0; n < count; ++n)
                 {
                         {
                                 std_v pool;
-				thrash_pool(length, pool);
+				fun(length, pool);
                         }
-			monotonic::static_storage.reset();
                 }
                 result.std_elapsed = timer.elapsed();
         }
 
-	cout << length << ": fast_pool, pool, std, mono: " << result.fast_pool_elapsed << ", " << result.pool_elapsed << ", " << result.std_elapsed << ", " << result.mono_elapsed << endl;
+	cout << length << ": fast_pool, pool, std, mono, local: " << result.fast_pool_elapsed << ", " << result.pool_elapsed << ", " << result.std_elapsed << ", " << result.mono_elapsed << ", " << result.local_mono_elapsed << endl;
         return result;
 }
 
-void compare_memory_pool()
+typedef std::map<size_t, PoolResult> PoolResults;
+
+template <class Fun>
+PoolResults compare_memory_pool(size_t count, size_t max_length, size_t num_iterations, Fun fun)
 {
-	const size_t count = 10000;
-	const size_t max_length = 10000;
-	
-	typedef std::map<size_t, PoolResult> Results;
-	Results results;
-	results[5] = compare_memory_pool(count*10, 5);
-	results[20] = compare_memory_pool(count*10, 20);
-	results[50] = compare_memory_pool(count*10, 50);
-	results[100] = compare_memory_pool(count*10, 100);
+	PoolResults results;
+	//results[5] = compare_memory_pool(count*100, 5, fun);
+	//results[20] = compare_memory_pool(count*100, 20, fun);
+	//results[50] = compare_memory_pool(count*100, 50, fun);
+	//results[100] = compare_memory_pool(count*100, 100, fun);
 
-	for (size_t length = 10; length < max_length; length += 1000)
+	for (size_t length = 10; length < max_length; length += max_length/num_iterations)
         {
-		results[length] = compare_memory_pool(count, length);
+		results[length] = compare_memory_pool(count, length, fun);
         }
-	cout << "count\t" << "fast_pool\t" << "pool\t" << "std\t" << "mono\n" << "fast_pool/mono" << endl;
-	BOOST_FOREACH(Results::value_type const &iter, results)
+	return results;
+}
+
+void compare_memory_pool()
+{
+	size_t num_outter_loops = 1000;
+	PoolResults r0 = compare_memory_pool(num_outter_loops, 10000, 10, thrash_pool());
+	cout << "thrash_pool" << endl;
+	cout << "count\t" << "fast_p\t" << "pool\t" << "std\t" << "local\t" << "mono\t" << "fp/mono\t" << "fp/local" << endl;
+	BOOST_FOREACH(PoolResults::value_type const &iter, r0)
+	{
+		PoolResult const &result = iter.second;
+		cout << iter.first << '\t' << result.fast_pool_elapsed << '\t' << result.pool_elapsed << "\t" << result.std_elapsed << '\t' << result.local_mono_elapsed << '\t' << result.mono_elapsed << '\t' << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%\t" << '\t' << 100.*result.fast_pool_elapsed/result.local_mono_elapsed << endl;
+	}
+
+	PoolResults r1 = compare_memory_pool(num_outter_loops, 1000, 10, thrash_pool_sort());
+	cout << "thrash_pool_sort" << endl;
+	cout << "count\t" << "fast_p\t" << "pool\t" << "std\t" << "local\t" << "mono\t" << "fp/mono\t" << "fp/local" << endl;
+	BOOST_FOREACH(PoolResults::value_type const &iter, r1)
         {
                 PoolResult const &result = iter.second;
-		cout << iter.first << '\t' << result.fast_pool_elapsed << '\t' << result.pool_elapsed << "\t\t" << result.std_elapsed << '\t' << result.mono_elapsed << '\t' << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%" << endl;
+		cout << iter.first << '\t' << result.fast_pool_elapsed << '\t' << result.pool_elapsed << "\t" << result.std_elapsed << '\t' << result.local_mono_elapsed << '\t' << result.mono_elapsed << '\t' << 100.*result.fast_pool_elapsed/result.mono_elapsed << "%\t" << '\t' << 100.*result.fast_pool_elapsed/result.local_mono_elapsed << endl;
         }
 }
 
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -9,6 +9,7 @@
 //#include <boost/monotonic/shared_storage.hpp>
 //#include <boost/monotonic/shared_allocator.hpp>
 
+#include <boost/monotonic/local.hpp>
 #include <boost/monotonic/static_storage.hpp>
 
 #include <boost/monotonic/vector.hpp>
@@ -49,37 +50,37 @@
 
 void test_deque()
 {
-	monotonic::storage<4000> storage;
+	monotonic::local<> storage;
         {
                 {
-			std::list<int, boost::monotonic::allocator<int> > list(storage);
+			std::list<int, boost::monotonic::allocator<int> > list;
                         fill_n(back_inserter(list), 100, 42);
                         cout << "list: " << storage.used() << endl;
                 }
                 storage.reset();
                 {
-			std::deque<int, boost::monotonic::allocator<int> > deque(storage);
+			std::deque<int, boost::monotonic::allocator<int> > deque;
                         fill_n(back_inserter(deque), 100, 42);
                         cout << "deque: " << storage.used() << endl;
                 }
                 storage.reset();
 
                 {
-			std::vector<int, boost::monotonic::allocator<int> > vector(storage);
+			std::vector<int, boost::monotonic::allocator<int> > vector;
                         fill_n(back_inserter(vector), 100, 42);
                         cout << "vector: " << storage.used() << endl;
                 }
                 storage.reset();
 
                 {
-			monotonic::chain<int> chain(storage);
+			monotonic::chain<int> chain;
                         fill_n(back_inserter(chain), 100, 42);
                         cout << "default chain: " << storage.used() << endl;
                 }
                 storage.reset();
 
                 {
-			monotonic::chain<int, 100> chain(storage);
+			monotonic::chain<int, 100> chain;
                         fill_n(back_inserter(chain), 100, 42);
                         cout << "chain<100>: " << storage.used() << endl;
                 }
@@ -89,83 +90,41 @@
 
 void test_speed()
 {
+	monotonic::local<monotonic::storage<1000000> > storage;
         typedef monotonic::map<int, monotonic::list<int> > map_with_list;
-	monotonic::storage<1000000> storage;
-	map_with_list m(storage);
-	size_t count = 10000;
-	boost::timer timer;
-	for (size_t i = 0; i < count; ++i)
         {
-		int random = rand() % 100;
-		map_with_list::iterator iter = m.find(random);
-		if (iter == m.end())
-			m.insert(make_pair(random, monotonic::list<int>(storage)));
-		else
-			iter->second.push_back(i);
-	}
-	double elapsed = timer.elapsed();
-	cout << "monotonic: " << elapsed << endl;
-
-	// do the same thing, with std::containers
-	{
-		typedef std::map<int, std::list<int> > map_with_list;
                 map_with_list m;
+		size_t count = 10000;
                 boost::timer timer;
                 for (size_t i = 0; i < count; ++i)
                 {
                         int random = rand() % 100;
                         map_with_list::iterator iter = m.find(random);
                         if (iter == m.end())
-				m[random] = std::list<int>();
-			else
-				iter->second.push_back(i);
-		}
-		double elapsed = timer.elapsed();
-		cout << "std: " << elapsed << endl;
-	}
-}
-
-void test_speed_heap()
-{
-	size_t num_iterations = 100000;
-
-	typedef monotonic::map<int, monotonic::list<int> > map_with_list;
-	monotonic::storage<1000000> *storage = new monotonic::storage<1000000>;
-
-	// do the test with monotonic containers and heap-based storage
-	{
-		map_with_list m(*storage);
-		boost::timer timer;
-		for (size_t i = 0; i < num_iterations; ++i)
-		{
-			int random = rand() % 100;
-			map_with_list::iterator iter = m.find(random);
-			if (iter == m.end())
-				m.insert(make_pair(random, monotonic::list<int>(*storage)));
+				m.insert(make_pair(random, monotonic::list<int>()));
                         else
                                 iter->second.push_back(i);
                 }
                 double elapsed = timer.elapsed();
                 cout << "monotonic: " << elapsed << endl;
-	}
-	delete storage;
 
-	// do the same thing, with std::containers
-	{
-		typedef std::map<int, std::list<int> > map_with_list;
-		map_with_list m;
-		boost::timer timer;
-		for (size_t i = 0; i < num_iterations; ++i)
+		// do the same thing, with std::containers
                 {
-			int random = rand() % 100;
-			map_with_list::iterator iter = m.find(random);
-			if (iter == m.end())
-				m[random] = std::list<int>();
-			else
-				iter->second.push_back(i);
+			typedef std::map<int, std::list<int> > map_with_list;
+			map_with_list m;
+			boost::timer timer;
+			for (size_t i = 0; i < count; ++i)
+			{
+				int random = rand() % 100;
+				map_with_list::iterator iter = m.find(random);
+				if (iter == m.end())
+					m[random] = std::list<int>();
+				else
+					iter->second.push_back(i);
+			}
+			double elapsed = timer.elapsed();
+			cout << "std: " << elapsed << endl;
                 }
-		double elapsed = timer.elapsed();
-		cout << "std: " << elapsed << endl;
         }
 }
 
@@ -184,8 +143,8 @@
         template<typename C>
         void test_loop_monotonic()
         {
-		boost::monotonic::storage<100000> storage;
-		std::vector<Foo<C>, monotonic::allocator<Foo<C> > > vec(storage);
+		monotonic::local<> storage;
+		std::vector<Foo<C>, monotonic::allocator<Foo<C> > > vec;
                 Foo<C> orig = { 'A', 65 };
                 vec.assign(ELEM_COUNT, orig);
                 boost::timer timer;
@@ -236,13 +195,13 @@
         typedef boost::array<char, 57> c5;
         typedef boost::array<char, 111> c6;
 
-	monotonic::vector<c0> v0(storage);
-	monotonic::vector<c1> v1(storage);
-	monotonic::vector<c2> v2(storage);
-	monotonic::vector<c3> v3(storage);
-	monotonic::vector<c4> v4(storage);
-	monotonic::vector<c5> v5(storage);
-	monotonic::vector<c6> v6(storage);
+	monotonic::vector<c0> v0;
+	monotonic::vector<c1> v1;
+	monotonic::vector<c2> v2;
+	monotonic::vector<c3> v3;
+	monotonic::vector<c4> v4;
+	monotonic::vector<c5> v5;
+	monotonic::vector<c6> v6;
 
         v0.resize(5);
         v1.resize(5);
@@ -295,7 +254,9 @@
 { 
         namespace monotonic 
         {
-		static_storage_base<> static_storage;
+		static_storage_base<> default_static_storage;
+		storage_base *static_storage = &default_static_storage;
+
                 //storage<> static_storage_base<storage<> >::global;
         }
 }
@@ -303,7 +264,7 @@
 void test_static_storage()
 {
         // reset the global static storage to zero use
-	monotonic::static_storage.reset();
+	boost::monotonic::get_storage().reset();
 
         typedef std::list<int, monotonic::allocator<int> > List;
         typedef std::map<int, List, std::less<int>, monotonic::allocator<int> > Map;
@@ -316,8 +277,8 @@
                 map[42] = list0;
                 map[123] = list1;
         }
-	cout << monotonic::static_storage.used() << endl;
-	monotonic::static_storage.reset();
+	cout << monotonic::get_storage().used() << endl;
+	boost::monotonic::get_storage().reset();
 }
 
 void run_all_tests()
@@ -338,7 +299,7 @@
 
 void test_mono_map()
 {
-	monotonic::storage<> store;
+	monotonic::local<> store;
 /*
 // commented out till i add the required libraries for boost::mutex :/
 
@@ -358,31 +319,33 @@
         }
 */
 
-	{
-		typedef std::list<int, monotonic::allocator<int> > List;
-		BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<List>::value);
-		typedef std::map<int, List, std::less<int>, monotonic::allocator<int> > Map;
-		BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<Map>::value);
-		Map map(less<int>(), store);
-		//map[42].push_back(123);
-		map.insert(make_pair(42, List(store)));
-		map[42].push_back(123);
-		BOOST_ASSERT(map[42].get_allocator().get_storage() == map.get_allocator().get_storage());
-	}
+	// this can't work in general:
+	//{
+	//	typedef std::list<int, monotonic::allocator<int> > List;
+	//	BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<List>::value);
+	//	typedef std::map<int, List, std::less<int>, monotonic::allocator<int> > Map;
+	//	BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<Map>::value);
+	//	Map map(less<int>(), store);
+	//	//map[42].push_back(123);
+	//	map.insert(make_pair(42, List(store)));
+	//	map[42].push_back(123);
+	//	BOOST_ASSERT(map[42].get_allocator().get_storage() == map.get_allocator().get_storage());
+	//}
 
+	// but this can:
         {
                 typedef monotonic::list<int> List;
                 BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<List>::value);
                 typedef monotonic::map<int, List > Map;
                 BOOST_STATIC_ASSERT(monotonic::detail::is_monotonic<Map>::value);
-		Map map(store);
+		Map map;
                 map[42].push_back(123);
                 BOOST_ASSERT(map[42].get_allocator().get_storage() == map.get_allocator().get_storage());
         }
 
         {
                 typedef monotonic::map<int, monotonic::map<int, monotonic::list<int> > > Map;
-		Map map(store);
+		Map map;
                 map[42][64].push_back(13);
                 BOOST_ASSERT(map[42][64].get_allocator().get_storage() == map.get_allocator().get_storage());
         }
@@ -399,6 +362,7 @@
 }
 #endif
 
+
 int main()
 {
 #ifdef WIN32
@@ -406,10 +370,10 @@
 #endif
 
         //test_chained_storage();
-	compare_memory_pool();
+	test_map_list_heap_stack();
+	//compare_memory_pool();
         //test_mono_map();
         //test_mono_map();
-	//test_map_list_heap_stack();
         //test_static_storage();
         //run_all_tests();
 }
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -123,7 +123,7 @@
                                 EnableFunctionLevelLinking="true"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
-				DebugInformationFormat="0"
+				DebugInformationFormat="3"
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"
@@ -216,6 +216,10 @@
 					>
                                 </File>
                                 <File
+					RelativePath="..\..\..\boost\monotonic\local.hpp"
+					>
+				</File>
+				<File
                                         RelativePath="..\..\..\boost\monotonic\map.hpp"
 					>
                                 </File>
@@ -352,6 +356,22 @@
                 <File
                         RelativePath=".\rope.cpp"
 			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				ExcludedFromBuild="true"
+				>
+				<Tool
+					Name="VCCLCompilerTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				ExcludedFromBuild="true"
+				>
+				<Tool
+					Name="VCCLCompilerTool"
+				/>
+			</FileConfiguration>
                 </File>
                 <File
                         RelativePath=".\test_bubble_sort.cpp"
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -47,9 +47,9 @@
 void test_chain()
 {
         {
-		monotonic::storage<> storage;
+		monotonic::local<> storage;
                 {
-			monotonic::chain<int, 100> rope(storage);
+			monotonic::chain<int, 100> rope;
                         for (int n = 0; n < 200; ++n)
                         {
                                 rope.push_back(n);
@@ -58,13 +58,13 @@
         }
 
 
-	monotonic::storage<> storage;
+	monotonic::local<> storage;
         {
                 typedef monotonic::chain<Foo, 2> Rope2;
-		Rope2 foo(4, storage);
+		Rope2 foo(4);
 
                 typedef monotonic::chain<int, 2> Rope;
-		Rope rope(storage);
+		Rope rope;
                 rope.push_back(0);
                 rope.push_back(1);
                 rope.push_back(2);
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -25,12 +25,12 @@
 
 pair<double,double> test_bubble_sort(size_t count = 50*1000, size_t length = 20)
 {
-	monotonic::storage<> storage;
+	monotonic::local<> storage;
         boost::timer mono_timer;
         for (size_t n = 0; n < count; ++n)
         {
                 {
-			std::list<int, monotonic::allocator<int> > list(storage);
+			std::list<int, monotonic::allocator<int> > list;
                         test_bubble_sort_impl(length, list);
                 }
                 storage.reset();
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -3,10 +3,10 @@
 
 void test_chained_storage()
 {
-	monotonic::storage<0, 16> store;
+	monotonic::local<monotonic::storage<0, 16> > store;
         {
                 typedef std::vector<char, monotonic::allocator<char> > Vector;
-		Vector vec(store);
+		Vector vec;
                 vec.resize(5);		// still on the stack
                 vec.resize(32);		// now on the heap
                 vec.resize(500);	// now on the heap
Modified: sandbox/monotonic/libs/monotonic/test/test_dupe.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/test_dupe.cpp	(original)
+++ sandbox/monotonic/libs/monotonic/test/test_dupe.cpp	2009-06-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -14,12 +14,12 @@
 
 pair<double,double> test_dupe(size_t num_tests, size_t count, size_t size)
 {
-	monotonic::storage<1000000> storage;
+	monotonic::local<> storage;
 
         boost::timer mono_timer;
         for (size_t n = 0; n < num_tests; ++n)
         {
-		std::list<int, monotonic::allocator<int> > list(storage);
+		std::list<int, monotonic::allocator<int> > list;
                 test_dupe_impl(count, size, list);
                 storage.reset();
         }
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-18 02:50:46 EDT (Thu, 18 Jun 2009)
@@ -40,7 +40,7 @@
                 for (size_t n = 0; n < outter_loops; ++n)
                 {
                         {
-				MonoMap map(std::less<int>(), storage);
+				MonoMap map;
                                 test_map_list_impl(inner_loops, map);
                         }
                         storage.reset();
@@ -64,15 +64,17 @@
         // use static monotonic allocator
         {
                 boost::timer timer;
-		monotonic::static_storage.reset();
+		boost::monotonic::storage_base *current = &monotonic::get_storage();
+		boost::monotonic::default_storage();
                 for (size_t n = 0; n < outter_loops; ++n)
                 {
                         {
                                 MonoMap map;
                                 test_map_list_impl(inner_loops, map);
                         }
-			monotonic::static_storage.reset();
+			boost::monotonic::reset_storage();
                 }
+		boost::monotonic::set_storage(*current);
                 result.static_monotonic = timer.elapsed();
         }
 
@@ -89,7 +91,7 @@
         typedef std::map<size_t, Result > Results;
         Results results;
 
-	monotonic::storage<> storage;
+	monotonic::local<> storage;
         for (size_t inner = 100; inner < inner_loops; inner += 1000)
         {
                 results[inner] = test_map_list(outter_loops, inner, storage);