Boost logo

Boost-Commit :

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


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

Log:
file renames

Added:
   sandbox/monotonic/boost/monotonic/fixed_storage.h
      - copied unchanged from r53959, /sandbox/monotonic/boost/monotonic/storage.h
   sandbox/monotonic/boost/monotonic/storage.h
      - copied, changed from r53959, /sandbox/monotonic/boost/monotonic/chained_storage.h
Removed:
   sandbox/monotonic/boost/monotonic/chained_storage.h
Text files modified:
   sandbox/monotonic/boost/monotonic/storage.h | 3 ++-
   sandbox/monotonic/libs/monotonic/test/main.cpp | 2 +-
   sandbox/monotonic/libs/monotonic/test/test_chained_storage.cpp | 2 +-
   3 files changed, 4 insertions(+), 3 deletions(-)

Deleted: sandbox/monotonic/boost/monotonic/chained_storage.h
==============================================================================
--- sandbox/monotonic/boost/monotonic/chained_storage.h 2009-06-15 23:10:15 EDT (Mon, 15 Jun 2009)
+++ (empty file)
@@ -1,159 +0,0 @@
-// 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)
-
-#pragma once
-
-#include <boost/monotonic/storage.h>
-#include <utility>
-
-namespace boost
-{
- namespace monotonic
- {
- /// storage that spans the stack/heap boundary.
- ///
- /// 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 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;
-
- /// a link in the chain of heap-based memory buffers
- struct Link
- {
- size_t capacity, cursor;
- char *buffer;
- CharAllocator alloc;
- Link() : capacity(0), cursor(0), buffer(0)
- {
- }
- Link(Allocator const &al, size_t cap)
- : capacity(cap), cursor(0), buffer(0), alloc(al)
- {
- }
- void Construct()
- {
- buffer = alloc.allocate(capacity);
- if (buffer == 0)
- capacity = 0;
- }
- ~Link()
- {
- alloc.deallocate(buffer, 1);
- }
- void reset()
- {
- cursor = 0;
- }
- size_t used() const
- {
- return cursor;
- }
- bool CanAllocate(size_t num_bytes) const
- {
- return capacity - cursor >= num_bytes;
- }
- inline void *Allocate(size_t num_bytes, size_t alignment)
- {
- size_t extra = cursor & (alignment - 1);
- if (extra > 0)
- extra = alignment - extra;
- size_t required = num_bytes + extra;
- if (capacity - cursor < required)
- return 0;
- char *ptr = buffer + cursor;
- cursor += required;
- return ptr + extra;
- }
- };
- typedef std::vector<Link, Al> Chain;
-
- private:
- fixed_storage<InlineSize> fixed; // the inline fixed_storage
- Chain chain; // heap-based fixed_storage
- Allocator alloc; // allocator for heap-based fixed_storage
-
- public:
- storage()
- {
- }
- storage(Allocator const &A)
- : alloc(A)
- {
- }
-
- void reset()
- {
- fixed.reset();
- BOOST_FOREACH(Link &link, chain)
- {
- link.reset();
- }
- }
-
- void *allocate(size_t num_bytes, size_t alignment)
- {
- if (void *ptr = fixed.allocate(num_bytes, alignment))
- {
- return ptr;
- }
- BOOST_FOREACH(Link &link, chain)
- {
- if (void *ptr = link.Allocate(num_bytes, alignment))
- {
- return ptr;
- }
- }
- size_t size = std::max(MinHeapSize, num_bytes*2);
- 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();
- }
-
- size_t fixed_remaining() const
- {
- return fixed.remaining();
- }
-
- size_t remaining() const
- {
- return max_size();
- }
-
- size_t used() const
- {
- size_t count = fixed.used();
- BOOST_FOREACH(Link const &link, chain)
- count += link.used();
- return count;
- }
-
- private:
- Link &AddLink(size_t size)
- {
- chain.push_back(Link(alloc, size));
- Link &link = chain.back();
- link.Construct();
- return link;
- }
- };
-
- } // namespace monotonic
-
-} // namespace boost
-
-//EOF

Copied: sandbox/monotonic/boost/monotonic/storage.h (from r53959, /sandbox/monotonic/boost/monotonic/chained_storage.h)
==============================================================================
--- /sandbox/monotonic/boost/monotonic/chained_storage.h (original)
+++ sandbox/monotonic/boost/monotonic/storage.h 2009-06-15 23:10:15 EDT (Mon, 15 Jun 2009)
@@ -5,7 +5,8 @@
 
 #pragma once
 
-#include <boost/monotonic/storage.h>
+#include <boost/monotonic/fixed_storage.h>
+#include <boost/foreach.hpp>
 #include <utility>
 
 namespace boost

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:10:15 EDT (Mon, 15 Jun 2009)
@@ -25,7 +25,7 @@
 #include <boost/scoped_ptr.hpp>
 
 #include <boost/monotonic/chain.h>
-#include <boost/monotonic/chained_storage.h>
+#include <boost/monotonic/storage.h>
 
 template <class T
 , size_t C = 64

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:10:15 EDT (Mon, 15 Jun 2009)
@@ -1,5 +1,5 @@
 
-#include <boost/monotonic/chained_storage.h>
+#include <boost/monotonic/storage.h>
 
 void test_chained_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