summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/IceUtil/Handle.h16
-rw-r--r--cpp/include/IceUtil/Shared.h55
2 files changed, 12 insertions, 59 deletions
diff --git a/cpp/include/IceUtil/Handle.h b/cpp/include/IceUtil/Handle.h
index df233134548..683afe62869 100644
--- a/cpp/include/IceUtil/Handle.h
+++ b/cpp/include/IceUtil/Handle.h
@@ -98,10 +98,10 @@ inline bool operator==(const HandleBase<T>& lhs, const HandleBase<U>& rhs)
{
return *l == *r;
}
- else
- {
- return !l && !r;
- }
+
+ // Note: don't use if { } else { }. This causes lots warnings when
+ // compiling with GCC and optimization enabled. See bug 2330.
+ return !l && !r;
}
template<typename T, typename U>
@@ -119,10 +119,10 @@ inline bool operator<(const HandleBase<T>& lhs, const HandleBase<U>& rhs)
{
return *l < *r;
}
- else
- {
- return !l && r;
- }
+
+ // Note: don't use if { } else { }. This causes lots warnings when
+ // compiling with GCC and optimization enabled. See bug 2330.
+ return !l && r;
}
template<typename T, typename U>
diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h
index c80b6b35c5b..61b466d9895 100644
--- a/cpp/include/IceUtil/Shared.h
+++ b/cpp/include/IceUtil/Shared.h
@@ -197,57 +197,10 @@ public:
return *this;
}
- void __incRef()
- {
-#if defined(_WIN32)
- assert(InterlockedExchangeAdd(&_ref, 0) >= 0);
- InterlockedIncrement(&_ref);
-#elif defined(ICE_HAS_ATOMIC_FUNCTIONS)
- assert(ice_atomic_exchange_add(0, &_ref) >= 0);
- ice_atomic_inc(&_ref);
-#else
- _mutex.lock();
- assert(_ref >= 0);
- ++_ref;
- _mutex.unlock();
-#endif
- }
-
- void __decRef()
- {
-#if defined(_WIN32)
- assert(InterlockedExchangeAdd(&_ref, 0) > 0);
- if(InterlockedDecrement(&_ref) == 0 && !_noDelete)
- {
- _noDelete = true;
- delete this;
- }
-#elif defined(ICE_HAS_ATOMIC_FUNCTIONS)
- assert(ice_atomic_exchange_add(0, &_ref) > 0);
- if(ice_atomic_dec_and_test(&_ref) && !_noDelete)
- {
- _noDelete = true;
- delete this;
- }
-#else
- _mutex.lock();
- bool doDelete = false;
- assert(_ref > 0);
- if(--_ref == 0)
- {
- doDelete = !_noDelete;
- _noDelete = true;
- }
- _mutex.unlock();
- if(doDelete)
- {
- delete this;
- }
-#endif
- }
-
- int __getRef() const;
- void __setNoDelete(bool);
+ virtual void __incRef();
+ virtual void __decRef();
+ virtual int __getRef() const;
+ virtual void __setNoDelete(bool);
protected: