mirror of
https://github.com/boostorg/detail.git
synced 2025-07-30 12:27:15 +02:00
Fixed bug #1370716, static shared_ptr instances not working w/ quick_allocator
[SVN r31931]
This commit is contained in:
@ -71,7 +71,15 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOOST_HAS_THREADS
|
#ifdef BOOST_HAS_THREADS
|
||||||
static lightweight_mutex mutex;
|
|
||||||
|
static lightweight_mutex & mutex()
|
||||||
|
{
|
||||||
|
static lightweight_mutex m;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
static lightweight_mutex * mutex_init;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static block * free;
|
static block * free;
|
||||||
@ -81,7 +89,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
|||||||
static inline void * alloc()
|
static inline void * alloc()
|
||||||
{
|
{
|
||||||
#ifdef BOOST_HAS_THREADS
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mutex);
|
lightweight_mutex::scoped_lock lock( mutex() );
|
||||||
#endif
|
#endif
|
||||||
if(block * x = free)
|
if(block * x = free)
|
||||||
{
|
{
|
||||||
@ -111,7 +119,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef BOOST_HAS_THREADS
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mutex);
|
lightweight_mutex::scoped_lock lock( mutex() );
|
||||||
#endif
|
#endif
|
||||||
if(block * x = free)
|
if(block * x = free)
|
||||||
{
|
{
|
||||||
@ -136,7 +144,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
|||||||
if(pv != 0) // 18.4.1.1/13
|
if(pv != 0) // 18.4.1.1/13
|
||||||
{
|
{
|
||||||
#ifdef BOOST_HAS_THREADS
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mutex);
|
lightweight_mutex::scoped_lock lock( mutex() );
|
||||||
#endif
|
#endif
|
||||||
block * pb = static_cast<block *>(pv);
|
block * pb = static_cast<block *>(pv);
|
||||||
pb->next = free;
|
pb->next = free;
|
||||||
@ -153,7 +161,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
|||||||
else if(pv != 0) // 18.4.1.1/13
|
else if(pv != 0) // 18.4.1.1/13
|
||||||
{
|
{
|
||||||
#ifdef BOOST_HAS_THREADS
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mutex);
|
lightweight_mutex::scoped_lock lock( mutex() );
|
||||||
#endif
|
#endif
|
||||||
block * pb = static_cast<block *>(pv);
|
block * pb = static_cast<block *>(pv);
|
||||||
pb->next = free;
|
pb->next = free;
|
||||||
@ -163,8 +171,10 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BOOST_HAS_THREADS
|
#ifdef BOOST_HAS_THREADS
|
||||||
|
|
||||||
template<unsigned size, unsigned align_>
|
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
|
#endif
|
||||||
|
|
||||||
template<unsigned size, unsigned align_>
|
template<unsigned size, unsigned align_>
|
||||||
|
Reference in New Issue
Block a user