summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl')
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl57
1 files changed, 54 insertions, 3 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl
index 5e16e7d04f1..ad651ceb555 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl
+++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl
@@ -1,26 +1,77 @@
// $Id$
+#include "ace/Log_Msg.h"
+
template <class T> ACE_INLINE
TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (T *t)
: t_ (t)
{
- this->t_->_incr_refcnt ();
+ if (this->t_ != 0)
+ {
+ this->t_->_incr_refcnt ();
+ }
+}
+
+template <class T> ACE_INLINE
+TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (const TAO_Notify_Refcountable_Guard_T<T> &rhs)
+ : t_ (rhs.t_)
+{
+ if (this->t_ != 0)
+ {
+ this->t_->_incr_refcnt ();
+ }
}
template <class T> ACE_INLINE
TAO_Notify_Refcountable_Guard_T<T>::~TAO_Notify_Refcountable_Guard_T ()
{
- this->t_->_decr_refcnt ();
+ if (this->t_ != 0)
+ {
+ this->t_->_decr_refcnt ();
+ }
+}
+
+template <class T> ACE_INLINE T*
+TAO_Notify_Refcountable_Guard_T<T>::get (void) const
+{
+ return this->t_;
}
template <class T> ACE_INLINE T*
TAO_Notify_Refcountable_Guard_T<T>::operator-> (void) const
{
+ ACE_ASSERT (this->t_ != 0);
return this->t_;
}
-template <class T> ACE_INLINE T&
+template <class T> ACE_INLINE
+T&
TAO_Notify_Refcountable_Guard_T<T>::operator *(void) const
{
+ ACE_ASSERT (this->t_ != 0);
return *this->t_;
}
+
+template <class T> ACE_INLINE
+TAO_Notify_Refcountable_Guard_T<T> &
+TAO_Notify_Refcountable_Guard_T<T>::operator = (
+ const TAO_Notify_Refcountable_Guard_T<T> & rhs)
+{
+ // note exception safe assignment. see Sutter's "Exceptional C++"
+ // note it's worth the following optimization to avoid threadsafe increment/decrement refcounters
+ if (this->t_ != rhs.t_) {
+ TAO_Notify_Refcountable_Guard_T<T> temp(rhs.t_);
+ swap (temp);
+}
+ return *this;
+}
+
+
+template <class T> ACE_INLINE
+void
+TAO_Notify_Refcountable_Guard_T<T>::swap (TAO_Notify_Refcountable_Guard_T & rhs)
+{
+ T* pt = rhs.t_;
+ rhs.t_ = this->t_;
+ this->t_ = pt;
+}