Boost logo

Boost-Commit :

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


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

Log:
updated local<>

Text files modified:
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp | 11 ++++---
   sandbox/monotonic/boost/monotonic/local.hpp | 31 ++++++++++++++++----
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp | 57 +++++++++++++++++++++++++++++----------
   3 files changed, 72 insertions(+), 27 deletions(-)

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:22:07 EDT (Tue, 23 Jun 2009)
@@ -48,11 +48,12 @@
                 }
         
                 /// a RIIA structure for accessing and releasing storage
- template <size_t N = DefaultSizes::InlineSize
- , class Region = default_region_tag
- , size_t M = DefaultSizes::MinHeapIncrement
- , class Access = default_access_tag
- , class Al = std::allocator<void> >
+ //template <size_t N = DefaultSizes::InlineSize
+ // , class Region = default_region_tag
+ // , size_t M = DefaultSizes::MinHeapIncrement
+ // , class Access = default_access_tag
+ // , class Al = std::allocator<void> >
+ template <class Region = default_region_tag, class Access = default_access_tag>
                 struct local;
 
                 /// thread-safe storage

Modified: sandbox/monotonic/boost/monotonic/local.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/local.hpp (original)
+++ sandbox/monotonic/boost/monotonic/local.hpp 2009-06-23 01:22:07 EDT (Tue, 23 Jun 2009)
@@ -13,15 +13,15 @@
         namespace monotonic
         {
                 /// RIIA for storage
- template <size_t InlineSize
- , class Region
- , size_t MinHeapIncrement
- , class Access
- , class Al
- >
+ template <class Region, class Access>
                 struct local
                 {
- typedef static_storage<Region,Access,InlineSize,MinHeapIncrement,Al> StaticStorage;
+ typedef static_storage<
+ Region
+ , Access
+ , DefaultSizes::InlineSize
+ , DefaultSizes::MinHeapIncrement
+ , std::allocator<void> > StaticStorage;
 
                         local()
                         {
@@ -42,6 +42,23 @@
                         {
                                 get_storage().release();
                         }
+
+ template <class Ty>
+ Ty &create()
+ {
+ return get_storage().create<Ty>();
+ }
+ template <class Ty>
+ Ty &create(Ty const &X)
+ {
+ return get_storage().create<Ty>(X);
+ }
+ template <class Ty>
+ void destroy(Ty &X)
+ {
+ get_storage().destroy(X);
+ }
+
                 };
 
         } // namespace monotonic

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:22:07 EDT (Tue, 23 Jun 2009)
@@ -27,7 +27,7 @@
 using namespace boost;
 
 /// region tag for local storage used in run_test
-struct local_tag {};
+struct my_local {};
 
 template <class Fun>
 PoolResult run_test(size_t count, size_t length, Fun fun, Type types)
@@ -99,20 +99,20 @@
                 result.mono_elapsed = timer.elapsed();
         }
 
- if (types.Includes(Type::Monotonic))
- {
- srand(42);
- monotonic::local<64*1024, local_tag> storage;
- boost::timer timer;
- for (size_t n = 0; n < count; ++n)
- {
- {
- fun.test(monotonic::allocator<void, local_tag>(), length);
- }
- storage.reset();
- }
- result.local_mono_elapsed = timer.elapsed();
- }
+ //if (types.Includes(Type::Monotonic))
+ //{
+ // srand(42);
+ // monotonic::local<my_local> storage;
+ // boost::timer timer;
+ // for (size_t n = 0; n < count; ++n)
+ // {
+ // {
+ // fun.test(monotonic::allocator<void, my_local>(), length);
+ // }
+ // storage.reset();
+ // }
+ // result.local_mono_elapsed = timer.elapsed();
+ //}
 
         if (types.Includes(Type::Standard))
         {
@@ -268,6 +268,32 @@
 #pragma warning(disable:4996)
 #endif
 
+struct local_1 {};
+
+void test_locals()
+{
+ monotonic::local<local_1> storage;
+ {
+ std::list<int, monotonic::allocator<int, local_1> > list;
+ 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;
+ 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;
+
+ }
+}
+
 void test_pools()
 {
         size_t length = 1;
@@ -340,6 +366,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_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