|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53965 - sandbox/monotonic/boost/monotonic
From: christian.schladetsch_at_[hidden]
Date: 2009-06-16 00:12:51
Author: cschladetsch
Date: 2009-06-16 00:12:50 EDT (Tue, 16 Jun 2009)
New Revision: 53965
URL: http://svn.boost.org/trac/boost/changeset/53965
Log:
added/removed some comments
Text files modified:
sandbox/monotonic/boost/monotonic/allocator.h | 1 -
sandbox/monotonic/boost/monotonic/fixed_storage.h | 33 ++++++++++++---------------------
sandbox/monotonic/boost/monotonic/shared_storage.h | 4 ----
sandbox/monotonic/boost/monotonic/storage.h | 5 -----
sandbox/monotonic/boost/monotonic/storage_base.h | 11 +++++++----
5 files changed, 19 insertions(+), 35 deletions(-)
Modified: sandbox/monotonic/boost/monotonic/allocator.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/allocator.h (original)
+++ sandbox/monotonic/boost/monotonic/allocator.h 2009-06-16 00:12:50 EDT (Tue, 16 Jun 2009)
@@ -8,7 +8,6 @@
#include <boost/monotonic/storage_base.h>
#include <boost/monotonic/storage.h>
#include <boost/assert.hpp>
-//#include <boost/swap.hpp>
#include <boost/type_traits/has_trivial_constructor.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
Modified: sandbox/monotonic/boost/monotonic/fixed_storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/fixed_storage.h (original)
+++ sandbox/monotonic/boost/monotonic/fixed_storage.h 2009-06-16 00:12:50 EDT (Tue, 16 Jun 2009)
@@ -26,15 +26,11 @@
template <size_t N>
struct fixed_storage : storage_base
{
-
-#ifdef BOOST_MONOTONIC_USE_AUTOBUFFER
- typedef boost::auto_buffer<char, boost::store_n_bytes<N> > buffer_type;
-#else
- typedef boost::array<char, N> buffer_type;
-#endif
+ BOOST_STATIC_ASSERT(N > 0);
+ typedef boost::array<char, N> Buffer;
private:
- buffer_type buffer; ///< the storage
+ Buffer buffer; ///< the storage
size_t cursor; ///< pointer to current index within storage for next allocation
#ifndef NDEBUG
size_t num_allocations;
@@ -48,7 +44,7 @@
{
}
- buffer_type const &get_buffer() const
+ Buffer const &get_buffer() const
{
return buffer;
}
@@ -81,9 +77,6 @@
/// allocate storage, given alignment requirement
void *allocate(size_t num_bytes, size_t alignment)
{
-#ifndef NDEBUG
- ++num_allocations;
-#endif
// ensure we return a point on an aligned boundary
size_t extra = cursor & (alignment - 1);
if (extra > 0)
@@ -93,20 +86,14 @@
{
return 0;
}
-#ifdef BOOST_MONOTONIC_USE_AUTOBUFFER
- buffer.uninitialized_resize(buffer.size() + required);
+#ifndef NDEBUG
+ ++num_allocations;
#endif
char *ptr = &buffer[cursor];
cursor += required;
return ptr + extra;
}
- /// no work is done to deallocate storage
- void deallocate(void * /*p*/, size_t /*n*/)
- {
- }
-
- /// the maximum size is determined at compile-time
size_t max_size() const
{
return N;
@@ -116,10 +103,12 @@
{
return N - cursor;
}
+
size_t used() const
{
return cursor;
}
+
#ifndef NDEBUG
size_t get_num_allocs() const
{
@@ -127,7 +116,9 @@
}
#endif
};
- }
-}
+
+ } // namespace monotonic
+
+} // namespace boost
//EOF
Modified: sandbox/monotonic/boost/monotonic/shared_storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_storage.h (original)
+++ sandbox/monotonic/boost/monotonic/shared_storage.h 2009-06-16 00:12:50 EDT (Tue, 16 Jun 2009)
@@ -44,10 +44,6 @@
mutex::scoped_lock lock(guard);
return storage.allocate(num_bytes, alignment);
}
- void deallocate(void *, size_t)
- {
- // do nothing
- }
size_t remaining() const
{
mutex::scoped_lock lock(guard);
Modified: sandbox/monotonic/boost/monotonic/storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.h (original)
+++ sandbox/monotonic/boost/monotonic/storage.h 2009-06-16 00:12:50 EDT (Tue, 16 Jun 2009)
@@ -116,11 +116,6 @@
return AddLink(size).Allocate(num_bytes, alignment);
}
- void deallocate(void *, size_t)
- {
- // do nothing
- }
-
size_t max_size() const
{
return std::numeric_limits<size_t>::max();
Modified: sandbox/monotonic/boost/monotonic/storage_base.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage_base.h (original)
+++ sandbox/monotonic/boost/monotonic/storage_base.h 2009-06-16 00:12:50 EDT (Tue, 16 Jun 2009)
@@ -9,16 +9,19 @@
{
namespace monotonic
{
- /// base structure for inline_storage<N>
+ /// base structure for different storage types
struct storage_base
{
+ // reset the number of bytes used to zero
+ virtual void reset() = 0;
+
// the number of bytes to allocate, and the alignment to use
virtual void *allocate(size_t num_bytes, size_t alignment) = 0;
-
- virtual void deallocate(void *base, size_t num_bytes) = 0;
+
virtual size_t max_size() const = 0;
+
+ /// return the number of bytes remaining
virtual size_t remaining() const = 0;
- virtual void reset() = 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