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:
Peter Dimov
2002-02-15 18:07:42 +00:00
parent 875bab352c
commit 7981b647c3
2 changed files with 13 additions and 22 deletions

View File

@ -24,30 +24,9 @@ namespace detail
class lightweight_mutex
{
private:
lightweight_mutex(lightweight_mutex const &);
lightweight_mutex & operator=(lightweight_mutex const &);
public:
lightweight_mutex()
{
}
class scoped_lock
{
private:
scoped_lock(scoped_lock const &);
scoped_lock & operator=(scoped_lock const &);
public:
explicit scoped_lock(lightweight_mutex &)
{
}
};
typedef lightweight_mutex scoped_lock;
};
} // namespace detail

View File

@ -74,7 +74,9 @@ public:
void add_ref()
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mtx_);
#endif
if(use_count_ == 0) throw use_count_is_zero();
++use_count_;
++weak_count_;
@ -86,7 +88,9 @@ public:
long new_weak_count;
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mtx_);
#endif
new_use_count = --use_count_;
new_weak_count = --weak_count_;
}
@ -106,7 +110,9 @@ public:
void weak_add_ref() // nothrow
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mtx_);
#endif
++weak_count_;
}
@ -115,7 +121,9 @@ public:
long new_weak_count;
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mtx_);
#endif
new_weak_count = --weak_count_;
}
@ -127,7 +135,9 @@ public:
long use_count() const // nothrow
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock(mtx_);
#endif
return use_count_;
}
@ -145,7 +155,9 @@ private:
long use_count_;
long weak_count_;
#ifdef BOOST_HAS_THREADS
mutable lightweight_mutex mtx_;
#endif
void (*self_deleter_) (counted_base *);
};