Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54805 - in sandbox/monotonic: . boost/monotonic libs/monotonic
From: christian.schladetsch_at_[hidden]
Date: 2009-07-08 15:55:06


Author: cschladetsch
Date: 2009-07-08 15:55:05 EDT (Wed, 08 Jul 2009)
New Revision: 54805
URL: http://svn.boost.org/trac/boost/changeset/54805

Log:
moved boost.png

Added:
   sandbox/monotonic/libs/monotonic/boost.png
      - copied unchanged from r54785, /sandbox/monotonic/boost.png
Removed:
   sandbox/monotonic/boost.png
Text files modified:
   sandbox/monotonic/boost/monotonic/fixed_storage.hpp | 2 +-
   sandbox/monotonic/boost/monotonic/stack.hpp | 17 +++++++++++++++--
   sandbox/monotonic/boost/monotonic/storage.hpp | 33 +++++++++++++++++++++++----------
   3 files changed, 39 insertions(+), 13 deletions(-)

Deleted: sandbox/monotonic/boost.png
==============================================================================
Binary file. No diff available.

Modified: sandbox/monotonic/boost/monotonic/fixed_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/fixed_storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/fixed_storage.hpp 2009-07-08 15:55:05 EDT (Wed, 08 Jul 2009)
@@ -101,7 +101,7 @@
 
             AllocationAttempt TryAllocation(size_t num_bytes, size_t alignment)
             {
- size_t extra = cursor & (alignment - 1);
+ size_t extra = cursor & (alignment - 1); // assumes alignment is a power of 2!
                 if (extra > 0)
                     extra = alignment - extra;
                 size_t required = num_bytes + extra;

Modified: sandbox/monotonic/boost/monotonic/stack.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/stack.hpp (original)
+++ sandbox/monotonic/boost/monotonic/stack.hpp 2009-07-08 15:55:05 EDT (Wed, 08 Jul 2009)
@@ -23,7 +23,7 @@
     {
         struct null_pointer {};
 
- /// a first-class stack object
+ /// a first-class fixed-size stack object
         template <size_t InlineSize>
         struct fixed_stack
         {
@@ -308,6 +308,7 @@
             }
         };
 
+ /// a growable stack
         template <size_t Size, size_t Inc, class Al>
         struct stack
         {
@@ -325,10 +326,22 @@
                 clear();
             }
 
+ void clear()
+ {
+
+ }
+ size_t top() const
+ {
+ return 0;
+ }
+ size_t size() const
+ {
+ return 0;
+ }
             template <class T>
             T &push()
             {
-
+ return fixed.push<T>();
             }
         };
     

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-07-08 15:55:05 EDT (Wed, 08 Jul 2009)
@@ -37,9 +37,10 @@
             // allocations are always made from the stack, or from a pool the first link in the chain
             typedef std::vector<Link, Alloc> Chain;
             typedef boost::array<Pool, NumPools> Pools;
+ typedef fixed_storage<InlineSize> FixedStorage; // the inline fixed-sized storage which may be on the stack
 
         private:
- fixed_storage<InlineSize> fixed; // the inline fixed-sized storage which may be on the stack
+ FixedStorage fixed; // the inline fixed-sized storage which may be on the stack
             Chain chain; // heap-based storage
             Allocator alloc; // allocator for heap-based storage
             Pools pools; // pools of same-sized chunks
@@ -94,13 +95,19 @@
 
             struct Allocation
             {
- void *ptr;
                 size_t cursor;
                 Pool *pool;
                 Link *link;
+ void *ptr;
+ fixed_storage_type *fixed;
+
 
                 Allocation()
- : pool(0), link(0), cursor(0), ptr(0) { }
+ : cursor(0), pool(0), link(0), ptr(0), fixed(0) { }
+ Allocation(Pool *p, void *result)
+ : cursor(0), pool(p), link(0), ptr(result), fixed(0) { }
+ Allocation(fixed_storage_type *p, size_t cursor, void *result)
+ : cursor(cursor), pool(p), link(0), ptr(result), fixed(p) { }
 
                 void undo()
                 {
@@ -114,10 +121,11 @@
                         link->set_cursor(cursor);
                         return;
                     }
- if (storage)
+ if (fixed)
                     {
- storage->set_cursor(cursor);
+ fixed->set_cursor(cursor);
                     }
+ BOOST_ASSERT(0);
                 }
             };
             Allocation MakeAllocation(size_t num_bytes, size_t alignment = 4)
@@ -126,12 +134,17 @@
                 if (bucket < NumPools)
                 {
                     if (void *ptr = from_pool(bucket, num_bytes, alignment))
- return Allocation(bucket, ptr);
+ return Allocation(&pools[bucket], ptr);
                 }
- //if (fixed.
- //if (void *ptr = from_fixed(num_bytes, alignment))
- // return Allocation(
- return from_heap(num_bytes, alignment);
+ FixedStorage::AllocationAttempt attempt = fixed.TryAllocation(num_bytes, alignment);
+ if (attempt.able)
+ {
+ size_t restore_point = fixed.get_cursor();
+ return Allocation(&fixed, restore_point, fixed.MakeAllocation(attempt));
+ }
+ throw;
+ //void *ptr = from_heap(num_bytes, alignment);
+ //return Allocation(&chain.front(), restore_point, ptr);
             }
 
         public:


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