|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49025 - trunk/boost/pool
From: chris.newbold_at_[hidden]
Date: 2008-09-29 14:41:19
Author: cnewbold
Date: 2008-09-29 14:41:19 EDT (Mon, 29 Sep 2008)
New Revision: 49025
URL: http://svn.boost.org/trac/boost/changeset/49025
Log:
Fixes for tickets #2095 ("pool fails to compile with -fno-exceptions")
and #2359 ("Static initialization problems with
fast_pool_allocator"). Use boost::throw_exception. Explicitly
reference singleton_pool from allocator constructors to avoid troubles
due to unordered initializaiton of static data in class templates.
Text files modified:
trunk/boost/pool/pool_alloc.hpp | 47 +++++++++++++++++++++++++++++++++------
1 files changed, 39 insertions(+), 8 deletions(-)
Modified: trunk/boost/pool/pool_alloc.hpp
==============================================================================
--- trunk/boost/pool/pool_alloc.hpp (original)
+++ trunk/boost/pool/pool_alloc.hpp 2008-09-29 14:41:19 EDT (Mon, 29 Sep 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)
@@ -139,8 +155,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 +173,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 +213,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 +224,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)
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