Boost logo

Boost-Commit :

From: xushiweizh_at_[hidden]
Date: 2008-04-28 22:29:45


Author: xushiwei
Date: 2008-04-28 22:29:44 EDT (Mon, 28 Apr 2008)
New Revision: 44869
URL: http://svn.boost.org/trac/boost/changeset/44869

Log:
auto initialize tls_bloc_kpool.
Added:
   sandbox/memory/libs/memory/memory.cpp (contents, props changed)
Removed:
   sandbox/memory/boost/memory/config.hpp
Binary files modified:
   sandbox/memory/libs/memory/bin/win32/boost-memory.dll
Text files modified:
   sandbox/memory/boost/memory/basic.hpp | 48 ++++++++++++++++++++++++++++++----------
   sandbox/memory/boost/memory/thread/tls.hpp | 9 +++++++
   sandbox/memory/libs/memory/memory.dsp | 4 +++
   3 files changed, 49 insertions(+), 12 deletions(-)

Modified: sandbox/memory/boost/memory/basic.hpp
==============================================================================
--- sandbox/memory/boost/memory/basic.hpp (original)
+++ sandbox/memory/boost/memory/basic.hpp 2008-04-28 22:29:44 EDT (Mon, 28 Apr 2008)
@@ -12,10 +12,6 @@
 #ifndef __BOOST_MEMORY_BASIC_HPP__
 #define __BOOST_MEMORY_BASIC_HPP__
 
-#ifndef __BOOST_MEMORY_CONFIG_HPP__
-#include "config.hpp"
-#endif
-
 // -------------------------------------------------------------------------
 
 #if !defined(_NEW_) && !defined(_NEW)
@@ -30,6 +26,27 @@
 #include <malloc.h> // _alloca
 #endif
 
+#ifndef _CrtSetDbgFlag
+
+#if defined(_MSC_VER)
+#include <crtdbg.h> // _CrtSetDbgFlag
+#endif
+
+#endif
+
+// =========================================================================
+
+#ifndef BOOST_MEMORY_CALL
+#define BOOST_MEMORY_CALL
+#endif
+
+// -------------------------------------------------------------------------
+
+#ifndef __NS_BOOST_BEGIN
+#define __NS_BOOST_BEGIN namespace boost {
+#define __NS_BOOST_END }
+#endif
+
 // =========================================================================
 // BOOST_MEMORY_ASSERT - diagnost
 
@@ -49,6 +66,21 @@
 #endif
 
 // =========================================================================
+// Configurations
+
+#ifndef BOOST_MEMORY_ALLOC_PADDING
+#define BOOST_MEMORY_ALLOC_PADDING 32
+#endif
+
+#ifndef BOOST_MEMORY_BLOCK_TOTAL
+#define BOOST_MEMORY_BLOCK_TOTAL 16384 // 16k
+#endif
+
+#ifndef BOOST_MEMORY_BLOCK_SIZE
+#define BOOST_MEMORY_BLOCK_SIZE (BOOST_MEMORY_BLOCK_TOTAL - BOOST_MEMORY_ALLOC_PADDING)
+#endif
+
+// =========================================================================
 // constructor_traits, destructor_traits
 
 __NS_BOOST_BEGIN
@@ -214,14 +246,6 @@
 
 // =========================================================================
 
-#ifndef _CrtSetDbgFlag
-
-#if defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-#endif
-
 __NS_BOOST_BEGIN
 
 inline void BOOST_MEMORY_CALL enableMemoryLeakCheck()

Deleted: sandbox/memory/boost/memory/config.hpp
==============================================================================
--- sandbox/memory/boost/memory/config.hpp 2008-04-28 22:29:44 EDT (Mon, 28 Apr 2008)
+++ (empty file)
@@ -1,45 +0,0 @@
-//
-// boost/memory/config.hpp
-//
-// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
-//
-// 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)
-//
-// See http://www.boost.org/libs/memory/index.htm for documentation.
-//
-#ifndef __BOOST_MEMORY_CONFIG_HPP__
-#define __BOOST_MEMORY_CONFIG_HPP__
-
-// -------------------------------------------------------------------------
-// Configurations
-
-#ifndef BOOST_MEMORY_ALLOC_PADDING
-#define BOOST_MEMORY_ALLOC_PADDING 32
-#endif
-
-#ifndef BOOST_MEMORY_BLOCK_TOTAL
-#define BOOST_MEMORY_BLOCK_TOTAL 16384 // 16k
-#endif
-
-#ifndef BOOST_MEMORY_BLOCK_SIZE
-#define BOOST_MEMORY_BLOCK_SIZE (BOOST_MEMORY_BLOCK_TOTAL - BOOST_MEMORY_ALLOC_PADDING)
-#endif
-
-// -------------------------------------------------------------------------
-
-#ifndef BOOST_MEMORY_CALL
-#define BOOST_MEMORY_CALL
-#endif
-
-// -------------------------------------------------------------------------
-
-#ifndef __NS_BOOST_BEGIN
-#define __NS_BOOST_BEGIN namespace boost {
-#define __NS_BOOST_END }
-#endif
-
-// -------------------------------------------------------------------------
-
-#endif /* __BOOST_MEMORY_CONFIG_HPP__ */

Modified: sandbox/memory/boost/memory/thread/tls.hpp
==============================================================================
--- sandbox/memory/boost/memory/thread/tls.hpp (original)
+++ sandbox/memory/boost/memory/thread/tls.hpp 2008-04-28 22:29:44 EDT (Mon, 28 Apr 2008)
@@ -35,6 +35,10 @@
         TLSINDEX m_key;
 
 public:
+ win_tls_key()
+ : m_key(TLS_OUT_OF_INDEXES) {
+ }
+
         void BOOST_MEMORY_CALL create() {
                 m_key = TlsAlloc();
         }
@@ -73,6 +77,10 @@
         pthread_key_t m_key;
 
 public:
+ pthread_tls_key()
+ : m_key(TLS_OUT_OF_INDEXES) {
+ }
+
         void BOOST_MEMORY_CALL create() {
                 pthread_key_create(&m_key, NULL);
         }
@@ -224,6 +232,7 @@
                 void* p = m_key.get();
                 if (p == NULL) {
                         m_key.put(p = Factory::create());
+ BOOST_MEMORY_ASSERT(m_key.get() == p);
                 }
                 return *(Type*)p;
         }

Modified: sandbox/memory/libs/memory/bin/win32/boost-memory.dll
==============================================================================
Binary files. No diff available.

Added: sandbox/memory/libs/memory/memory.cpp
==============================================================================
--- (empty file)
+++ sandbox/memory/libs/memory/memory.cpp 2008-04-28 22:29:44 EDT (Mon, 28 Apr 2008)
@@ -0,0 +1,34 @@
+// memory.cpp : Defines the entry point for the DLL application.
+//
+
+#include "stdafx.h"
+#include <boost/memory/scoped_alloc.hpp>
+
+// -------------------------------------------------------------------------
+
+using namespace boost;
+
+extern tls_block_pool_t _tls_blockPool;
+
+#if defined(_WIN32)
+
+BOOL APIENTRY DllMain(HANDLE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ _tls_blockPool.init();
+ break;
+ case DLL_PROCESS_DETACH:
+ _tls_blockPool.term();
+ break;
+ }
+ return TRUE;
+}
+
+#endif
+
+// -------------------------------------------------------------------------

Modified: sandbox/memory/libs/memory/memory.dsp
==============================================================================
--- sandbox/memory/libs/memory/memory.dsp (original)
+++ sandbox/memory/libs/memory/memory.dsp 2008-04-28 22:29:44 EDT (Mon, 28 Apr 2008)
@@ -100,6 +100,10 @@
 # PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=..\..\..\..\memory\sandbox\libs\memory\memory.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\memory_w32.def
 # End Source File
 # Begin Source File


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