Fixed bug #1370716, static shared_ptr instances not working w/ quick_allocator

[SVN r31931]
This commit is contained in:
Peter Dimov
2005-12-06 12:24:40 +00:00
parent 9d5b0d7c0c
commit 6dd212ccf7

View File

@ -71,7 +71,15 @@ template<unsigned size, unsigned align_> struct allocator_impl
#endif
#ifdef BOOST_HAS_THREADS
static lightweight_mutex mutex;
static lightweight_mutex & mutex()
{
static lightweight_mutex m;
return m;
}
static lightweight_mutex * mutex_init;
#endif
static block * free;
@ -81,7 +89,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
static inline void * alloc()
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mutex);
lightweight_mutex::scoped_lock lock( mutex() );
#endif
if(block * x = free)
{
@ -111,7 +119,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
else
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mutex);
lightweight_mutex::scoped_lock lock( mutex() );
#endif
if(block * x = free)
{
@ -136,7 +144,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
if(pv != 0) // 18.4.1.1/13
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mutex);
lightweight_mutex::scoped_lock lock( mutex() );
#endif
block * pb = static_cast<block *>(pv);
pb->next = free;
@ -153,7 +161,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
else if(pv != 0) // 18.4.1.1/13
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mutex);
lightweight_mutex::scoped_lock lock( mutex() );
#endif
block * pb = static_cast<block *>(pv);
pb->next = free;
@ -163,8 +171,10 @@ template<unsigned size, unsigned align_> struct allocator_impl
};
#ifdef BOOST_HAS_THREADS
template<unsigned size, unsigned align_>
lightweight_mutex allocator_impl<size, align_>::mutex;
lightweight_mutex allocator_impl<size, align_>::mutex_init = &lightweight_mutex allocator_impl<size, align_>::mutex();
#endif
template<unsigned size, unsigned align_>