Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49253 - in branches/release: boost/pool boost/pool/detail libs/pool/test
From: chris.newbold_at_[hidden]
Date: 2008-10-10 11:55:44


Author: cnewbold
Date: 2008-10-10 11:55:43 EDT (Fri, 10 Oct 2008)
New Revision: 49253
URL: http://svn.boost.org/trac/boost/changeset/49253

Log:
Merge current Boost.Pool code from trunk to release in preparation for 1.37.

Added:
   branches/release/libs/pool/test/Jamfile.v2
      - copied unchanged from r49252, /trunk/libs/pool/test/Jamfile.v2
   branches/release/libs/pool/test/pool_msvc_compiler_bug_test.cpp
      - copied unchanged from r49252, /trunk/libs/pool/test/pool_msvc_compiler_bug_test.cpp
Properties modified:
   branches/release/boost/pool/detail/for.m4 (props changed)
   branches/release/boost/pool/detail/pool_construct.inc (props changed)
   branches/release/boost/pool/detail/pool_construct.m4 (props changed)
   branches/release/boost/pool/detail/pool_construct_simple.inc (props changed)
   branches/release/boost/pool/detail/pool_construct_simple.m4 (props changed)
Text files modified:
   branches/release/boost/pool/detail/mutex.hpp | 20 +++++-----
   branches/release/boost/pool/pool_alloc.hpp | 77 +++++++++++++++++++++++++++++++++++----
   branches/release/libs/pool/test/test_pool_alloc.cpp | 17 ++++++++
   3 files changed, 96 insertions(+), 18 deletions(-)

Modified: branches/release/boost/pool/detail/mutex.hpp
==============================================================================
--- branches/release/boost/pool/detail/mutex.hpp (original)
+++ branches/release/boost/pool/detail/mutex.hpp 2008-10-10 11:55:43 EDT (Fri, 10 Oct 2008)
@@ -64,23 +64,23 @@
 class win32_mutex
 {
   private:
- CRITICAL_SECTION mtx;
+ ::CRITICAL_SECTION mtx;
 
     win32_mutex(const win32_mutex &);
     void operator=(const win32_mutex &);
 
   public:
     win32_mutex()
- { InitializeCriticalSection(&mtx); }
+ { ::InitializeCriticalSection(&mtx); }
 
     ~win32_mutex()
- { DeleteCriticalSection(&mtx); }
+ { ::DeleteCriticalSection(&mtx); }
 
     void lock()
- { EnterCriticalSection(&mtx); }
+ { ::EnterCriticalSection(&mtx); }
 
     void unlock()
- { LeaveCriticalSection(&mtx); }
+ { ::LeaveCriticalSection(&mtx); }
 };
 
 #endif // defined(BOOST_WINDOWS)
@@ -90,23 +90,23 @@
 class pthread_mutex
 {
   private:
- pthread_mutex_t mtx;
+ ::pthread_mutex_t mtx;
 
     pthread_mutex(const pthread_mutex &);
     void operator=(const pthread_mutex &);
 
   public:
     pthread_mutex()
- { pthread_mutex_init(&mtx, 0); }
+ { ::pthread_mutex_init(&mtx, 0); }
 
     ~pthread_mutex()
- { pthread_mutex_destroy(&mtx); }
+ { ::pthread_mutex_destroy(&mtx); }
 
     void lock()
- { pthread_mutex_lock(&mtx); }
+ { ::pthread_mutex_lock(&mtx); }
 
     void unlock()
- { pthread_mutex_unlock(&mtx); }
+ { ::pthread_mutex_unlock(&mtx); }
 };
 
 #endif // defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)

Modified: branches/release/boost/pool/pool_alloc.hpp
==============================================================================
--- branches/release/boost/pool/pool_alloc.hpp (original)
+++ branches/release/boost/pool/pool_alloc.hpp 2008-10-10 11:55:43 EDT (Fri, 10 Oct 2008)
@@ -14,6 +14,7 @@
 // new, std::bad_alloc
 #include <new>
 
+#include <boost/throw_exception.hpp>
 #include <boost/pool/poolfwd.hpp>
 
 // boost::singleton_pool
@@ -57,7 +58,15 @@
     };
 
   public:
- pool_allocator() { }
+ pool_allocator()
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
+ NextSize>::is_from(0);
+ }
 
     // default copy constructor
 
@@ -66,7 +75,14 @@
     // not explicit, mimicking std::allocator [20.4.1]
     template <typename U>
     pool_allocator(const pool_allocator<U, UserAllocator, Mutex, NextSize> &)
- { }
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
+ NextSize>::is_from(0);
+ }
 
     // default destructor
 
@@ -95,7 +111,7 @@
           singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
               NextSize>::ordered_malloc(n) );
       if (ret == 0)
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
       return ret;
     }
     static pointer allocate(const size_type n, const void * const)
@@ -111,6 +127,21 @@
     }
 };
 
+template<
+ typename UserAllocator,
+ typename Mutex,
+ unsigned NextSize>
+class pool_allocator<void, UserAllocator, Mutex, NextSize>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind {
+ typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ };
+};
+
 struct fast_pool_allocator_tag { };
 
 template <typename T,
@@ -139,8 +170,16 @@
     };
 
   public:
- fast_pool_allocator() { }
-
+ fast_pool_allocator()
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize>::is_from(0);
+ }
+
     // default copy constructor
 
     // default assignment operator
@@ -149,7 +188,14 @@
     template <typename U>
     fast_pool_allocator(
         const fast_pool_allocator<U, UserAllocator, Mutex, NextSize> &)
- { }
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize>::is_from(0);
+ }
 
     // default destructor
 
@@ -182,7 +228,7 @@
               singleton_pool<fast_pool_allocator_tag, sizeof(T),
                   UserAllocator, Mutex, NextSize>::ordered_malloc(n) );
       if (ret == 0)
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
       return ret;
     }
     static pointer allocate(const size_type n, const void * const)
@@ -193,7 +239,7 @@
           singleton_pool<fast_pool_allocator_tag, sizeof(T),
               UserAllocator, Mutex, NextSize>::malloc() );
       if (ret == 0)
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
       return ret;
     }
     static void deallocate(const pointer ptr, const size_type n)
@@ -216,6 +262,21 @@
     }
 };
 
+template<
+ typename UserAllocator,
+ typename Mutex,
+ unsigned NextSize>
+class fast_pool_allocator<void, UserAllocator, Mutex, NextSize>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind {
+ typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ };
+};
+
 } // namespace boost
 
 #endif

Modified: branches/release/libs/pool/test/test_pool_alloc.cpp
==============================================================================
--- branches/release/libs/pool/test/test_pool_alloc.cpp (original)
+++ branches/release/libs/pool/test/test_pool_alloc.cpp 2008-10-10 11:55:43 EDT (Fri, 10 Oct 2008)
@@ -304,11 +304,28 @@
     std::cout << "Memory error" << std::endl;
 }
 
+void test_void()
+{
+#ifdef VERBOSE
+ std::cout << "Testing void specialization. . ." << std::endl;
+#endif
+
+ typedef boost::pool_allocator<void> void_allocator;
+ typedef boost::fast_pool_allocator<void> fast_void_allocator;
+
+ typedef void_allocator::rebind<int>::other int_allocator;
+ typedef fast_void_allocator::rebind<int>::other fast_int_allocator;
+
+ std::vector<int, int_allocator> v1;
+ std::vector<int, fast_int_allocator> v2;
+}
+
 int test_main(int, char * [])
 {
   test();
   test_alloc();
   test_mem_usage();
+ test_void();
 
 #ifdef VERBOSE
   std::cout << "main() exiting. . ." << std::endl;


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