|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-05-04 09:32:28
Author: xushiwei
Date: 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
New Revision: 45109
URL: http://svn.boost.org/trac/boost/changeset/45109
Log:
boost memory policy
Text files modified:
sandbox/memory/boost/memory.hpp | 16 ++++++++--------
sandbox/memory/boost/memory/auto_alloc.hpp | 2 +-
sandbox/memory/boost/memory/gc_alloc.hpp | 10 +++++++++-
sandbox/memory/boost/memory/policy.hpp | 10 ++++++++--
sandbox/memory/boost/memory/scoped_alloc.hpp | 8 ++++----
sandbox/memory/boost/memory/system_alloc.hpp | 2 +-
sandbox/memory/boost/memory/system_pool.hpp | 6 +++---
sandbox/memory/boost/memory/threadmodel/multi_thread.hpp | 3 +--
8 files changed, 35 insertions(+), 22 deletions(-)
Modified: sandbox/memory/boost/memory.hpp
==============================================================================
--- sandbox/memory/boost/memory.hpp (original)
+++ sandbox/memory/boost/memory.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -157,18 +157,18 @@
{
namespace memory {}
- using boost::memory::system_alloc;
+ using NS_BOOST_MEMORY::system_alloc;
- using boost::memory::block_pool;
- using boost::memory::tls_block_pool;
+ using NS_BOOST_MEMORY::block_pool;
+ using NS_BOOST_MEMORY::tls_block_pool;
- using boost::memory::auto_alloc;
- using boost::memory::scoped_alloc;
- using boost::memory::gc_alloc;
+ using NS_BOOST_MEMORY::auto_alloc;
+ using NS_BOOST_MEMORY::scoped_alloc;
+ using NS_BOOST_MEMORY::gc_alloc;
- using boost::memory::stl_allocator;
+ using NS_BOOST_MEMORY::stl_allocator;
- using boost::memory::enableMemoryLeakCheck;
+ using NS_BOOST_MEMORY::enableMemoryLeakCheck;
}
#define BOOST_NO_CONSTRUCTOR(Type) BOOST_MEMORY_NO_CONSTRUCTOR(Type)
Modified: sandbox/memory/boost/memory/auto_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/auto_alloc.hpp (original)
+++ sandbox/memory/boost/memory/auto_alloc.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -209,7 +209,7 @@
// -------------------------------------------------------------------------
// class auto_alloc
-typedef region_alloc<policy::sys> auto_alloc;
+typedef region_alloc<NS_BOOST_MEMORY_POLICY::sys> auto_alloc;
// -------------------------------------------------------------------------
// $Log: auto_alloc.hpp,v $
Modified: sandbox/memory/boost/memory/gc_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/gc_alloc.hpp (original)
+++ sandbox/memory/boost/memory/gc_alloc.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -487,6 +487,14 @@
}
}
+ void* BOOST_MEMORY_CALL reallocate(void* p, size_t oldSize, size_t newSize)
+ {
+ void* p2 = allocate(newSize);
+ memcpy(p2, p, oldSize);
+ deallocate(p, oldSize);
+ return p2;
+ }
+
private:
template <class Type>
void BOOST_MEMORY_CALL _destroy(Type* obj, destructor_t)
@@ -579,7 +587,7 @@
// -------------------------------------------------------------------------
// class gc_alloc
-typedef gen_alloc<policy::pool> gc_alloc;
+typedef gen_alloc<NS_BOOST_MEMORY_POLICY::pool> gc_alloc;
// -------------------------------------------------------------------------
// $Log: gc_alloc.hpp,v $
Modified: sandbox/memory/boost/memory/policy.hpp
==============================================================================
--- sandbox/memory/boost/memory/policy.hpp (original)
+++ sandbox/memory/boost/memory/policy.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -117,7 +117,13 @@
// -------------------------------------------------------------------------
-namespace policy {
+#ifndef NS_BOOST_MEMORY_POLICY_BEGIN
+#define NS_BOOST_MEMORY_POLICY_BEGIN namespace policy {
+#define NS_BOOST_MEMORY_POLICY_END }
+#define NS_BOOST_MEMORY_POLICY policy
+#endif
+
+NS_BOOST_MEMORY_POLICY_BEGIN
class sys
{
@@ -137,7 +143,7 @@
typedef simple_gc_alloc<system_alloc> huge_gc_allocator;
};
-}
+NS_BOOST_MEMORY_POLICY_END
// -------------------------------------------------------------------------
// $Log: policy.hpp,v $
Modified: sandbox/memory/boost/memory/scoped_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/scoped_alloc.hpp (original)
+++ sandbox/memory/boost/memory/scoped_alloc.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -137,7 +137,7 @@
}
};
-typedef block_pool_imp<policy::sys> block_pool;
+typedef block_pool_imp<NS_BOOST_MEMORY_POLICY::sys> block_pool;
// -------------------------------------------------------------------------
// class tls_block_pool
@@ -184,7 +184,7 @@
typedef proxy_alloc<block_pool, tls_block_pool> proxy_block_pool;
-namespace policy {
+NS_BOOST_MEMORY_POLICY_BEGIN
class pool : public sys
{
@@ -192,9 +192,9 @@
typedef proxy_block_pool allocator_type;
};
-}
+NS_BOOST_MEMORY_POLICY_END
-typedef region_alloc<policy::pool> scoped_alloc;
+typedef region_alloc<NS_BOOST_MEMORY_POLICY::pool> scoped_alloc;
// -------------------------------------------------------------------------
// $Log: $
Modified: sandbox/memory/boost/memory/system_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/system_alloc.hpp (original)
+++ sandbox/memory/boost/memory/system_alloc.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -150,7 +150,7 @@
#define BOOST_MEMORY_NO_SYSTEM_POOL_DYN_
#endif
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(BOOST_MEMORY_NO_SYSTEM_POOL)
typedef system_pool_dyn system_alloc;
#else
typedef stdlib_alloc system_alloc;
Modified: sandbox/memory/boost/memory/system_pool.hpp
==============================================================================
--- sandbox/memory/boost/memory/system_pool.hpp (original)
+++ sandbox/memory/boost/memory/system_pool.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -128,7 +128,7 @@
// -------------------------------------------------------------------------
// class system_pool
-namespace policy {
+NS_BOOST_MEMORY_POLICY_BEGIN
class stdlib : public sys
{
@@ -136,9 +136,9 @@
typedef stdlib_alloc allocator_type;
};
-}
+NS_BOOST_MEMORY_POLICY_END
-typedef system_pool_s<policy::stdlib> system_pool;
+typedef system_pool_s<NS_BOOST_MEMORY_POLICY::stdlib> system_pool;
// -------------------------------------------------------------------------
// $Log: $
Modified: sandbox/memory/boost/memory/threadmodel/multi_thread.hpp
==============================================================================
--- sandbox/memory/boost/memory/threadmodel/multi_thread.hpp (original)
+++ sandbox/memory/boost/memory/threadmodel/multi_thread.hpp 2008-05-04 09:32:26 EDT (Sun, 04 May 2008)
@@ -39,7 +39,6 @@
{
}
-/* @@todo:
value_type BOOST_MEMORY_CALL acquire()
{
return InterlockedIncrement(&m_nRef);
@@ -49,7 +48,7 @@
{
return InterlockedDecrement(&m_nRef);
}
-*/
+
operator value_type()
{
return m_nRef;
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