forked from boostorg/smart_ptr
lwm_nop fixed to not emit warnings on g++; locking code #ifdef'ed since compilers sometimes have trouble removing it.
[SVN r12822]
This commit is contained in:
@ -24,30 +24,9 @@ namespace detail
|
|||||||
|
|
||||||
class lightweight_mutex
|
class lightweight_mutex
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
lightweight_mutex(lightweight_mutex const &);
|
|
||||||
lightweight_mutex & operator=(lightweight_mutex const &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
lightweight_mutex()
|
typedef lightweight_mutex scoped_lock;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
class scoped_lock
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
scoped_lock(scoped_lock const &);
|
|
||||||
scoped_lock & operator=(scoped_lock const &);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
explicit scoped_lock(lightweight_mutex &)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@ -74,7 +74,9 @@ public:
|
|||||||
|
|
||||||
void add_ref()
|
void add_ref()
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mtx_);
|
lightweight_mutex::scoped_lock lock(mtx_);
|
||||||
|
#endif
|
||||||
if(use_count_ == 0) throw use_count_is_zero();
|
if(use_count_ == 0) throw use_count_is_zero();
|
||||||
++use_count_;
|
++use_count_;
|
||||||
++weak_count_;
|
++weak_count_;
|
||||||
@ -86,7 +88,9 @@ public:
|
|||||||
long new_weak_count;
|
long new_weak_count;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mtx_);
|
lightweight_mutex::scoped_lock lock(mtx_);
|
||||||
|
#endif
|
||||||
new_use_count = --use_count_;
|
new_use_count = --use_count_;
|
||||||
new_weak_count = --weak_count_;
|
new_weak_count = --weak_count_;
|
||||||
}
|
}
|
||||||
@ -106,7 +110,9 @@ public:
|
|||||||
|
|
||||||
void weak_add_ref() // nothrow
|
void weak_add_ref() // nothrow
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mtx_);
|
lightweight_mutex::scoped_lock lock(mtx_);
|
||||||
|
#endif
|
||||||
++weak_count_;
|
++weak_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +121,9 @@ public:
|
|||||||
long new_weak_count;
|
long new_weak_count;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mtx_);
|
lightweight_mutex::scoped_lock lock(mtx_);
|
||||||
|
#endif
|
||||||
new_weak_count = --weak_count_;
|
new_weak_count = --weak_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +135,9 @@ public:
|
|||||||
|
|
||||||
long use_count() const // nothrow
|
long use_count() const // nothrow
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_HAS_THREADS
|
||||||
lightweight_mutex::scoped_lock lock(mtx_);
|
lightweight_mutex::scoped_lock lock(mtx_);
|
||||||
|
#endif
|
||||||
return use_count_;
|
return use_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +155,9 @@ private:
|
|||||||
|
|
||||||
long use_count_;
|
long use_count_;
|
||||||
long weak_count_;
|
long weak_count_;
|
||||||
|
#ifdef BOOST_HAS_THREADS
|
||||||
mutable lightweight_mutex mtx_;
|
mutable lightweight_mutex mtx_;
|
||||||
|
#endif
|
||||||
void (*self_deleter_) (counted_base *);
|
void (*self_deleter_) (counted_base *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user