diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-03-29 06:00:36 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-03-29 06:00:36 +0000 |
commit | c23ec0c39b80ce8127ebde65661d884d34b6ca79 (patch) | |
tree | 4e0565dc7ac99a2ba9058630331f8b25abcc83dc | |
parent | 0b8d2cdf0fad813b0aa9a2e26a156a7d1b12eec0 (diff) | |
download | ATCD-c23ec0c39b80ce8127ebde65661d884d34b6ca79.tar.gz |
ChangeLogTag:Mon Mar 28 21:38:42 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
-rw-r--r-- | TAO/ChangeLog | 39 | ||||
-rw-r--r-- | TAO/tao/Alias_TypeCode.cpp | 16 | ||||
-rw-r--r-- | TAO/tao/Fixed_TypeCode.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Makefile.am | 1 | ||||
-rw-r--r-- | TAO/tao/Null_RefCount_Policy.h | 1 | ||||
-rw-r--r-- | TAO/tao/RefCount_Policy_Traits.h | 107 | ||||
-rw-r--r-- | TAO/tao/Sequence_TypeCode.cpp | 19 | ||||
-rw-r--r-- | TAO/tao/String_TypeCode.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Value_Box_TypeCode.cpp | 16 | ||||
-rw-r--r-- | TAO/tao/tao.mpc | 1 |
10 files changed, 200 insertions, 4 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 28801f00494..acb49b467e5 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,40 @@ +Mon Mar 28 21:38:42 2005 Ossama Othman <ossama@dre.vanderbilt.edu> + + * tao/RefCount_Policy_Traits.h: + + New set of trait templates that facilitate compile-time + selection of reference count related operations based on which + of TAO::{Null,True}_RefCount_Policy template policy classes is + used. + + * tao/Alias_TypeCode.cpp (~Alias): + * tao/Sequence_TypeCode.cpp (~Sequence): + * tao/Value_Box_TypeCode.cpp (~Value_Box): + + Use the new TAO::RefCount_Policy_Traits<> template to make it + possible to completely elide a CORBA::release() function call on + the content type TypeCode when using the + TAO::Null_RefCount_Policy policy class. Addresses + invalid CORBA::release() calls on static content type TypeCodes + that are destroyed before the above enclosing TypeCodes get a + chance to call CORBA::release() on them. Fixes "pure virtual + method called" run-time errors upon process exit due to the + above TypeCode destructors calling CORBA::release() on their + previously destroyed static (i.e. declared as "static") content + type TypeCodes. + + * tao/Fixed_TypeCode.cpp: + * tao/String_TypeCode.cpp: + + Updated #include directives to conform to ACE/TAO coding + conventions. + + * tao/Makefile.am: + * tao/tao.mpc: + + Added new RefCount_Policy_Traits.h header to the header files + list. + Mon Mar 28 18:44:03 2005 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/tests/Event/Mcast/Simple/consumer.cpp: @@ -27,7 +64,7 @@ Mon Mar 28 02:15:09 2005 Ossama Othman <ossama@dre.vanderbilt.edu> * tao/DynamicAny/DynStruct_i.cpp: - Updated to use TAO TypeCode interface. + Updated to use new TAO TypeCode interface. Mon Mar 28 01:40:24 2005 Ossama Othman <ossama@dre.vanderbilt.edu> diff --git a/TAO/tao/Alias_TypeCode.cpp b/TAO/tao/Alias_TypeCode.cpp index 92f21652439..59d4ffd2c6f 100644 --- a/TAO/tao/Alias_TypeCode.cpp +++ b/TAO/tao/Alias_TypeCode.cpp @@ -12,14 +12,30 @@ #include "tao/TypeCodeFactory_Adapter.h" #include "tao/ORB_Core.h" #include "tao/CDR.h" +#include "tao/RefCount_Policy_Traits.h" + #include "ace/Dynamic_Service.h" template <typename StringType, class RefCountPolicy> TAO::TypeCode::Alias<StringType, RefCountPolicy>::~Alias (void) { +#if !defined (_MSC_VER) || (_MSC_VER >= 1310) + if (this->content_type_) + TAO::RefCount_Policy_Traits<RefCountPolicy, + CORBA::TypeCode_ptr>::release ( + *this->content_type_); + +#else + + // MSVC++ 6 can't handle partial template specializations. + + if (TAO::RefCount_Policy_Traits<RefCountPolicy>::is_refcounted () + && this->content_type_) CORBA::release (*this->content_type_); + +#endif /* !_MSC_VER ||_MSC_VER >= 1310 */ } template <typename StringType, class RefCountPolicy> diff --git a/TAO/tao/Fixed_TypeCode.cpp b/TAO/tao/Fixed_TypeCode.cpp index 177b7602d0f..54bc211e3a1 100644 --- a/TAO/tao/Fixed_TypeCode.cpp +++ b/TAO/tao/Fixed_TypeCode.cpp @@ -3,7 +3,7 @@ #ifndef TAO_FIXED_TYPECODE_CPP #define TAO_FIXED_TYPECODE_CPP -#include "Fixed_TypeCode.h" +#include "tao/Fixed_TypeCode.h" #ifndef __ACE_INLINE__ # include "tao/Fixed_TypeCode.inl" diff --git a/TAO/tao/Makefile.am b/TAO/tao/Makefile.am index fd68ae950bb..63c7e3410d6 100644 --- a/TAO/tao/Makefile.am +++ b/TAO/tao/Makefile.am @@ -711,6 +711,7 @@ nobase_include_HEADERS = \ Queued_Message.inl \ Reactive_Connect_Strategy.h \ Reactive_Flushing_Strategy.h \ + RefCount_Policy_Traits.h \ Refcounted_ObjectKey.h \ Refcounted_ObjectKey.inl \ Remote_Invocation.h \ diff --git a/TAO/tao/Null_RefCount_Policy.h b/TAO/tao/Null_RefCount_Policy.h index fd4ea8e2f57..8f8a25307cd 100644 --- a/TAO/tao/Null_RefCount_Policy.h +++ b/TAO/tao/Null_RefCount_Policy.h @@ -26,6 +26,7 @@ namespace TAO { + /** * @class Null_RefCount_Policy * diff --git a/TAO/tao/RefCount_Policy_Traits.h b/TAO/tao/RefCount_Policy_Traits.h new file mode 100644 index 00000000000..6f4ea6a2e00 --- /dev/null +++ b/TAO/tao/RefCount_Policy_Traits.h @@ -0,0 +1,107 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RefCount_Policy_Traits.h + * + * $Id$ + * + * Header file for TAO's reference count policy (unrelated to CORBA + * policies) traits. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_REFCOUNT_POLICY_TRAITS_H +#define TAO_REFCOUNT_POLICY_TRAITS_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/CORBA_methods.h" + + +namespace TAO +{ + class Null_RefCount_Policy; + class True_RefCount_Policy; + +#if !defined (_MSC_VER) || (_MSC_VER >= 1310) + /** + * @struct RefCount_Policy_Traits + * + * @brief Compile-time selection of RefCount_Policy operations, + * etc. + * + * This primary template is used to select RefCount_Policy + * operations, etc at compile-time based on the reference counting + * policy and type being operated on. + * + * @note This merely a forward declaration since we really only care + * about the partial specializations below. + */ + template<class RefCountPolicy, typename TypePtr> + struct RefCount_Policy_Traits; + + /** + * @struct RefCount_Policy_Traits + * + * @brief No-op reference count policy traits. + * + * This partial specialization performs no-op reference counting + * operations on values of type @a TypePtr if the @a RefCountPolicy + * first argument is @c Null_RefCount_Policy. + */ + template<typename TypePtr> + struct RefCount_Policy_Traits<Null_RefCount_Policy, TypePtr> + { + /// No-op "release" operation. + static void release (TypePtr) { } + }; + + template<typename TypePtr> + struct RefCount_Policy_Traits<True_RefCount_Policy, TypePtr> + { + /// Call actual "release" operation on @a ptr value. + static void release (TypePtr ptr) + { + CORBA::release (ptr); + } + }; + +#else + + // MSVC++ 6 can't handle partial template specializations so fall + // back on an alternate implementation. + + template<class RefCountPolicy> struct RefCount_Policy_Traits; + + template<> + struct RefCount_Policy_Traits<Null_RefCount_Policy> + { + static bool is_refcounted (void) + { + return false; + } + }; + + template<> + struct RefCount_Policy_Traits<True_RefCount_Policy> + { + static bool is_refcounted (void) + { + return true; + } + }; + +#endif /* !_MSC_VER || _MSC_VER >= 1310 */ + +} // End namespace TAO + +#include /**/ "ace/post.h" + +#endif /* TAO_REFCOUNT_POLICY_TRAITS_H */ diff --git a/TAO/tao/Sequence_TypeCode.cpp b/TAO/tao/Sequence_TypeCode.cpp index ac7a767778c..8dbd0ba8b12 100644 --- a/TAO/tao/Sequence_TypeCode.cpp +++ b/TAO/tao/Sequence_TypeCode.cpp @@ -3,17 +3,34 @@ #ifndef TAO_SEQUENCE_TYPECODE_CPP #define TAO_SEQUENCE_TYPECODE_CPP -#include "Sequence_TypeCode.h" +#include "tao/Sequence_TypeCode.h" #ifndef __ACE_INLINE__ # include "tao/Sequence_TypeCode.inl" #endif /* !__ACE_INLINE__ */ +#include "tao/RefCount_Policy_Traits.h" + + template <class RefCountPolicy> TAO::TypeCode::Sequence<RefCountPolicy>::~Sequence (void) { +#if !defined (_MSC_VER) || (_MSC_VER >= 1310) + if (this->content_type_) + TAO::RefCount_Policy_Traits<RefCountPolicy, + CORBA::TypeCode_ptr>::release ( + *this->content_type_); + +#else + + // MSVC++ 6 can't handle partial template specializations. + + if (TAO::RefCount_Policy_Traits<RefCountPolicy>::is_refcounted () + && this->content_type_) CORBA::release (*this->content_type_); + +#endif /* !_MSC_VER ||_MSC_VER >= 1310 */ } template <class RefCountPolicy> diff --git a/TAO/tao/String_TypeCode.cpp b/TAO/tao/String_TypeCode.cpp index 61800f5d3fe..37359bcfede 100644 --- a/TAO/tao/String_TypeCode.cpp +++ b/TAO/tao/String_TypeCode.cpp @@ -3,7 +3,7 @@ #ifndef TAO_STRING_TYPECODE_CPP #define TAO_STRING_TYPECODE_CPP -#include "String_TypeCode.h" +#include "tao/String_TypeCode.h" #ifndef __ACE_INLINE__ # include "tao/String_TypeCode.inl" diff --git a/TAO/tao/Value_Box_TypeCode.cpp b/TAO/tao/Value_Box_TypeCode.cpp index bd579b9a693..42097f004d8 100644 --- a/TAO/tao/Value_Box_TypeCode.cpp +++ b/TAO/tao/Value_Box_TypeCode.cpp @@ -9,12 +9,28 @@ # include "tao/Value_Box_TypeCode.inl" #endif /* !__ACE_INLINE__ */ +#include "tao/RefCount_Policy_Traits.h" + template <typename StringType, class RefCountPolicy> TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::~Value_Box (void) { +#if !defined (_MSC_VER) || (_MSC_VER >= 1310) + if (this->content_type_) + TAO::RefCount_Policy_Traits<RefCountPolicy, + CORBA::TypeCode_ptr>::release ( + *this->content_type_); + +#else + + // MSVC++ 6 can't handle partial template specializations. + + if (TAO::RefCount_Policy_Traits<RefCountPolicy>::is_refcounted () + && this->content_type_) CORBA::release (*this->content_type_); + +#endif /* !_MSC_VER ||_MSC_VER >= 1310 */ } template <typename StringType, class RefCountPolicy> diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index e31c698eeca..435e91f95ef 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -531,6 +531,7 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core { Queued_Message.h Reactive_Connect_Strategy.h Reactive_Flushing_Strategy.h + RefCount_Policy_Traits.h Refcounted_ObjectKey.h Remote_Invocation.h Remote_Object_Proxy_Broker.h |