Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52753 - in sandbox/memory/boost/memory: . container
From: xushiweizh_at_[hidden]
Date: 2009-05-04 05:47:04


Author: xushiwei
Date: 2009-05-04 05:47:03 EDT (Mon, 04 May 2009)
New Revision: 52753
URL: http://svn.boost.org/trac/boost/changeset/52753

Log:
object_pool::clear -
  bug fix: if ~Type() call object_pool::construct()?
Text files modified:
   sandbox/memory/boost/memory/container/dcl_list.hpp | 18 +++++++++---------
   sandbox/memory/boost/memory/object_pool.hpp | 22 ++++++++++++----------
   2 files changed, 21 insertions(+), 19 deletions(-)

Modified: sandbox/memory/boost/memory/container/dcl_list.hpp
==============================================================================
--- sandbox/memory/boost/memory/container/dcl_list.hpp (original)
+++ sandbox/memory/boost/memory/container/dcl_list.hpp 2009-05-04 05:47:03 EDT (Mon, 04 May 2009)
@@ -76,7 +76,7 @@
         }
 
 public:
- bool BOOST_MEMORY_CALL empty() const
+ __forceinline bool BOOST_MEMORY_CALL empty() const
         {
                 return m_next == this;
         }
@@ -99,13 +99,13 @@
                 m_prev = m_next = this;
         }
 
- void BOOST_MEMORY_CALL pop_front()
+ __forceinline void BOOST_MEMORY_CALL pop_front()
         {
                 BOOST_MEMORY_ASSERT(!empty());
                 static_cast<dcl_list_node_base_*>(m_next)->erase();
         }
 
- void BOOST_MEMORY_CALL pop_back()
+ __forceinline void BOOST_MEMORY_CALL pop_back()
         {
                 BOOST_MEMORY_ASSERT(!empty());
                 static_cast<dcl_list_node_base_*>(m_prev)->erase();
@@ -130,14 +130,14 @@
         }
 
 public:
- NodeT* BOOST_MEMORY_CALL next() { return (NodeT*)m_next; }
- const NodeT* BOOST_MEMORY_CALL next() const { return (const NodeT*)m_next; }
+ __forceinline NodeT* BOOST_MEMORY_CALL next() { return (NodeT*)m_next; }
+ __forceinline const NodeT* BOOST_MEMORY_CALL next() const { return (const NodeT*)m_next; }
 
- NodeT* BOOST_MEMORY_CALL prev() { return (NodeT*)m_prev; }
- const NodeT* BOOST_MEMORY_CALL prev() const { return (const NodeT*)m_prev; }
+ __forceinline NodeT* BOOST_MEMORY_CALL prev() { return (NodeT*)m_prev; }
+ __forceinline const NodeT* BOOST_MEMORY_CALL prev() const { return (const NodeT*)m_prev; }
 
- NodeT& BOOST_MEMORY_CALL data() { return *(NodeT*)this; }
- const NodeT& BOOST_MEMORY_CALL data() const { return *(const NodeT*)this; }
+ __forceinline NodeT& BOOST_MEMORY_CALL data() { return *(NodeT*)this; }
+ __forceinline const NodeT& BOOST_MEMORY_CALL data() const { return *(const NodeT*)this; }
 };
 
 // -------------------------------------------------------------------------

Modified: sandbox/memory/boost/memory/object_pool.hpp
==============================================================================
--- sandbox/memory/boost/memory/object_pool.hpp (original)
+++ sandbox/memory/boost/memory/object_pool.hpp 2009-05-04 05:47:03 EDT (Mon, 04 May 2009)
@@ -45,18 +45,18 @@
 #pragma pack()
 
 protected:
- __forceinline size_t BOOST_MEMORY_CALL is_allocated_(void*p )
+ __forceinline static size_t BOOST_MEMORY_CALL is_allocated_(void*p)
         {
                 return 1 & ((ChunkHeader*)p - 1)->tag;
         }
         
- __forceinline void BOOST_MEMORY_CALL mark_allocated_(void* p)
+ __forceinline static void BOOST_MEMORY_CALL mark_allocated_(void* p)
         {
                 BOOST_MEMORY_ASSERT(!is_allocated_(p));
                 ++((ChunkHeader*)p - 1)->tag;
         }
 
- __forceinline void BOOST_MEMORY_CALL mark_deallocated_(void* p)
+ __forceinline static void BOOST_MEMORY_CALL mark_deallocated_(void* p)
         {
                 BOOST_MEMORY_ASSERT(is_allocated_(p));
                 --((ChunkHeader*)p - 1)->tag;
@@ -85,11 +85,11 @@
         }
 
 private:
- void BOOST_MEMORY_CALL do_clear_block_(MemBlock* const blk)
+ static void BOOST_MEMORY_CALL do_clear_block_(MemBlock* const blk, size_t cbChunk)
         {
                 size_t nUsed = blk->nUsed;
                 char* p = blk->buffer + ChunkHeaderSize;
- for (;; p += this->m_cbChunk)
+ for (;; p += cbChunk)
                 {
                         if (is_allocated_(p))
                         {
@@ -103,16 +103,18 @@
 public:
         void BOOST_MEMORY_CALL clear()
         {
- MemBlock* nextBlk;
- for (MemBlock* blk = m_blks.first(); !m_blks.done(blk); blk = nextBlk)
+ MemBlock* blk = m_blks.first();
+
+ this->m_blks.clear();
+ this->m_freelist.clear();
+
+ for (MemBlock* nextBlk; !this->m_blks.done(blk); blk = nextBlk)
                 {
                         nextBlk = blk->next();
                         if (blk->nUsed)
- do_clear_block_(blk);
+ do_clear_block_(blk, this->m_cbChunk);
                         this->m_alloc.deallocate(blk);
                 }
- this->m_blks.clear();
- this->m_freelist.clear();
         }
 
 #if defined(BOOST_MEMORY_NO_STRICT_EXCEPTION_SEMANTICS)


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