Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54026 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-17 18:22:16


Author: cschladetsch
Date: 2009-06-17 18:22:13 EDT (Wed, 17 Jun 2009)
New Revision: 54026
URL: http://svn.boost.org/trac/boost/changeset/54026

Log:
added monotonic::shared_allocator
Added:
   sandbox/monotonic/boost/monotonic/shared_allocator.hpp (contents, props changed)
   sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp (contents, props changed)
Text files modified:
   sandbox/monotonic/boost/monotonic/shared_storage.hpp | 2 +-
   sandbox/monotonic/boost/monotonic/static_storage.hpp | 5 +++++
   sandbox/monotonic/boost/monotonic/storage.hpp | 2 +-
   sandbox/monotonic/boost/monotonic/storage_base.hpp | 6 ++++++
   sandbox/monotonic/libs/monotonic/test/main.cpp | 3 +++
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 16 ++++++++++++++++
   6 files changed, 32 insertions(+), 2 deletions(-)

Added: sandbox/monotonic/boost/monotonic/shared_allocator.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/shared_allocator.hpp 2009-06-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -0,0 +1,54 @@
+// 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_SHARED_ALLOCATOR_H
+#define BOOST_MONOTONIC_SHARED_ALLOCATOR_H
+
+#include <boost/monotonic/allocator.hpp>
+
+namespace boost
+{
+ namespace monotonic
+ {
+ template <class>
+ struct shared_allocator;
+
+ template <>
+ struct shared_allocator<void> : allocator<void>
+ {
+ };
+
+ template <class T>
+ struct shared_allocator : allocator<T>
+ {
+ shared_allocator() throw()
+ : storage(&static_shared_storage)
+ {
+ }
+
+ shared_allocator(shared_storage_base &store) throw()
+ : storage(&store)
+ {
+ }
+
+ shared_allocator(const shared_allocator& alloc) throw()
+ : storage(alloc.get_storage())
+ {
+ }
+
+ template <class U>
+ shared_allocator(const shared_allocator<U> &alloc) throw()
+ : storage(alloc.get_storage())
+ {
+ }
+ };
+
+ } // namespace monotonic
+
+} // namespace boost
+
+#endif // BOOST_MONOTONIC_ALLOCATOR_H
+
+//EOF

Modified: sandbox/monotonic/boost/monotonic/shared_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/shared_storage.hpp 2009-06-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -16,7 +16,7 @@
         {
                 /// thread-safe storage
                 template <size_t InlineSize, size_t MinHeapSize, class Al>
- struct shared_storage : storage_base
+ struct shared_storage : shared_storage_base
                 {
                         typedef storage<InlineSize, MinHeapSize, Al> Storage;
 

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-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -57,6 +57,11 @@
 
                 /// 'static_storage' will be used by a default-constructed monotonic::allocator
                 extern static_storage_base<> static_storage;
+
+ /// TODO: this will be specialised for
+ /// static_storage_base<..., shared_storage>, but to avoid having to link against boost::thread
+ /// it is currently synonymous with unshared storage ATM
+ extern static_storage_base<> static_shared_storage;
 
         } // namespace monotonic
 

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-06-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -14,7 +14,7 @@
         {
                 /// storage that spans the stack/heap boundary.
                 ///
- /// allocation requests first use inline fixed_storage of N bytes.
+ /// allocation requests first use inline fixed_storage of InlineSize bytes.
                 /// once that is exhausted, later requests are serviced from the heap.
                 ///
                 /// all allocations remain valid at all times.

Modified: sandbox/monotonic/boost/monotonic/storage_base.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage_base.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage_base.hpp 2009-06-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -32,6 +32,12 @@
                         /// return the number of bytes remaining
                         virtual size_t remaining() const = 0;
                 };
+
+ struct shared_storage_base : storage_base
+ {
+ //virtual void lock() const = 0;
+ //virtual void unlock() const = 0;
+ };
         
         } // namespace monotonic
 

Added: sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/libs/monotonic/test/compare_memory_pool.cpp 2009-06-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -0,0 +1,8 @@
+//#include <boost/me>
+
+void compare_memory_pool()
+{
+
+}
+
+//EOF

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-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -27,6 +27,7 @@
 
 #include <boost/monotonic/chain.hpp>
 #include <boost/monotonic/storage.hpp>
+#include <boost/monotonic/shared_allocator.hpp>
 
 template <class T
 , size_t C = 64
@@ -282,6 +283,7 @@
 #include "test_dupe.cpp"
 #include "test_chained_storage.cpp"
 #include "test_shared_storage.cpp"
+#include "compare_memory_pool.cpp"
 
 namespace boost
 {
@@ -389,6 +391,7 @@
         _set_se_translator(straight_to_debugger);
 #endif
 
+ compare_memory_pool();
         test_mono_map();
         test_map_list_heap_stack();
         //test_static_storage();

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-17 18:22:13 EDT (Wed, 17 Jun 2009)
@@ -224,6 +224,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\boost\monotonic\shared_allocator.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\boost\monotonic\shared_storage.hpp"
>
                                 </File>
@@ -318,6 +322,18 @@
                         </FileConfiguration>
                 </File>
                 <File
+ RelativePath=".\compare_memory_pool.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
                         RelativePath=".\main.cpp"
>
                 </File>


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