diff options
author | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-06-26 09:26:36 +0000 |
---|---|---|
committer | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-06-26 09:26:36 +0000 |
commit | 12cbc0a056b2fd94c2137fceefb82c1f6a8adb6e (patch) | |
tree | fab549be9031dc938de60e6490ae7e3f577afbb5 /TAO/tao/PI | |
parent | 09f151e9980fb754f3ccacccbf613fbe32791689 (diff) | |
download | ATCD-12cbc0a056b2fd94c2137fceefb82c1f6a8adb6e.tar.gz |
ChangeLogTag: Mon Jun 26 09:15:00 UTC 2006 Simon Massey <sma@prismtech.com>
Diffstat (limited to 'TAO/tao/PI')
-rw-r--r-- | TAO/tao/PI/ClientRequestInfo.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/PI/ClientRequestInfo.h | 17 | ||||
-rw-r--r-- | TAO/tao/PI/PICurrent.h | 1 | ||||
-rw-r--r-- | TAO/tao/PI/PICurrent_Copy_Callback.cpp | 67 | ||||
-rw-r--r-- | TAO/tao/PI/PICurrent_Copy_Callback.h | 80 | ||||
-rw-r--r-- | TAO/tao/PI/PICurrent_Impl.cpp | 96 | ||||
-rw-r--r-- | TAO/tao/PI/PICurrent_Impl.h | 68 | ||||
-rw-r--r-- | TAO/tao/PI/PICurrent_Impl.inl | 85 |
8 files changed, 109 insertions, 322 deletions
diff --git a/TAO/tao/PI/ClientRequestInfo.cpp b/TAO/tao/PI/ClientRequestInfo.cpp index d2af5d9a2e5..f3df9f77449 100644 --- a/TAO/tao/PI/ClientRequestInfo.cpp +++ b/TAO/tao/PI/ClientRequestInfo.cpp @@ -29,8 +29,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_ClientRequestInfo::TAO_ClientRequestInfo (TAO::Invocation_Base *inv) : invocation_ (inv), - rs_pi_current_ (), - copy_callback_ () + rs_pi_current_ () { this->setup_picurrent (); } @@ -55,19 +54,7 @@ TAO_ClientRequestInfo::setup_picurrent (void) if (tsc != 0) { // Logically copy the TSC's slot table to the RSC. - this->rs_pi_current_.lc_slot_table (tsc); - - // PICurrent will potentially have to call back on the request - // scope current so that it can deep copy the contents of the - // thread scope current if the contents of the thread scope - // current are about to be modified. It is necessary to do this - // deep copy once in order to completely isolate the request - // scope current from the thread scope current. This is only - // necessary, if the thread scope current is modified after its - // contents have been *logically* copied to the request scope - // current. - this->copy_callback_.src_and_dst (tsc, &this->rs_pi_current_); - tsc->copy_callback (&this->copy_callback_); + this->rs_pi_current_.take_lazy_copy (tsc); } } } diff --git a/TAO/tao/PI/ClientRequestInfo.h b/TAO/tao/PI/ClientRequestInfo.h index 40c83ff4c70..4671889f2b1 100644 --- a/TAO/tao/PI/ClientRequestInfo.h +++ b/TAO/tao/PI/ClientRequestInfo.h @@ -35,7 +35,6 @@ #include "tao/PI/ClientRequestInfoC.h" #include "tao/PI/PIForwardRequestC.h" #include "tao/PI/PICurrent_Impl.h" -#include "tao/PI/PICurrent_Copy_Callback.h" #include "tao/CORBA_methods.h" #include "tao/ORB_Constants.h" #include "tao/LocalObject.h" @@ -274,22 +273,6 @@ private: /// The "Request Scope Current" (RSC) object, as required by /// Portable Interceptors. TAO::PICurrent_Impl rs_pi_current_; - - /// Callback object to be executed when shallow copied slot table - /// must be deep copied. - /** - * This callback object deep copies the slot table from the TSC to - * the RSC. - * @par - * As an optimization, the TSC's slot table is initially only - * shallowed copied to the RSC. If the TSC's slot table will be - * modified, e.g. via PICurrent::set_slot(), it's slot table must be - * deep copied to the RSC before actually modifying that slot - * table. This is necessary since the RSC is read-only on the - * client side, meaning that changes in the TSC that occur after - * instantiation of the RSC must not be reflected in the RSC. - */ - TAO::PICurrent_Copy_Callback copy_callback_; }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PI/PICurrent.h b/TAO/tao/PI/PICurrent.h index 1425f5eec74..6f50a5d93da 100644 --- a/TAO/tao/PI/PICurrent.h +++ b/TAO/tao/PI/PICurrent.h @@ -42,7 +42,6 @@ class TAO_ORB_Core; namespace TAO { - class PICurrent_Copy_Callback; class PICurrent_Impl; /** diff --git a/TAO/tao/PI/PICurrent_Copy_Callback.cpp b/TAO/tao/PI/PICurrent_Copy_Callback.cpp deleted file mode 100644 index 9332b9c986a..00000000000 --- a/TAO/tao/PI/PICurrent_Copy_Callback.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "tao/PI/PICurrent_Copy_Callback.h" - -#if TAO_HAS_INTERCEPTORS == 1 - -#include "tao/PI/PICurrent_Impl.h" - -ACE_RCSID (tao, - PICurrent_Copy_Callback, - "$Id$") - - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -TAO::PICurrent_Copy_Callback::PICurrent_Copy_Callback (void) - : src_ (0), - dst_ (0) -{ -} - -TAO::PICurrent_Copy_Callback::~PICurrent_Copy_Callback (void) -{ - // Disable copy callbacks through this callback object in the source - // PICurrent_Impl object to prevent the source PICurrent_Impl from - // potentially calling back on a destructed copy callback object. - if (this->src_ != 0) - this->src_->copy_callback (0); -} - -void -TAO::PICurrent_Copy_Callback::execute (void) -{ - if (this->src_ != 0 && this->dst_ != 0 - && this->src_ != this->dst_) - { - // Only do a copy when the destination still refers to the table - // of the src - if (this->dst_->lc_slot_table () != 0) - { - const PICurrent_Impl::Table & s = this->src_->current_slot_table (); - - // Disable use of the logically copied slot table before - // performing the deep copy. - this->dst_->lc_slot_table (0); - - PICurrent_Impl::Table & d = this->dst_->slot_table (); - - d = s; - } - - // Prevent subsequent deep copies, effectively disabling this - // callback. - this->src_->copy_callback (0); - this->src_->destruction_callback (0); - } -} - -void -TAO::PICurrent_Copy_Callback::src_and_dst (PICurrent_Impl * src, - PICurrent_Impl * dst) -{ - this->src_ = src; - this->dst_ = dst; -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tao/PI/PICurrent_Copy_Callback.h b/TAO/tao/PI/PICurrent_Copy_Callback.h deleted file mode 100644 index 76f550e652f..00000000000 --- a/TAO/tao/PI/PICurrent_Copy_Callback.h +++ /dev/null @@ -1,80 +0,0 @@ -// -*- C++ -*- - -// =================================================================== -/** - * @file PICurrent_Copy_Callback.h - * - * $Id$ - * - * @author Ossama Othman <ossama@dre.vanderbilt.edu> - */ -// =================================================================== - -#ifndef TAO_PI_CURRENT_CALLBACK_H -#define TAO_PI_CURRENT_CALLBACK_H - -#include /**/ "ace/pre.h" - -#include "tao/PI/pi_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "tao/orbconf.h" - -#if TAO_HAS_INTERCEPTORS == 1 - - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO -{ - class PICurrent_Impl; - - /** - * @class PICurrent_Copy_Callback - * - * @brief PICurrent copy callback class. - * - * This class performs deep copies from the source PICurrent_Impl - * object's slot table to the destination PICurrent_Impl object's - * slot table. - */ - class TAO_PI_Export PICurrent_Copy_Callback - { - public: - - /// Constructor. - PICurrent_Copy_Callback (void); - - /// Destructor. - ~PICurrent_Copy_Callback (void); - - /// Perform the copy. - void execute (void); - - /// Set the source and destination PICurrent_Impl objects. - void src_and_dst (PICurrent_Impl * src, PICurrent_Impl * dst); - - private: - /// Disallow copying and assignment. - PICurrent_Copy_Callback (const PICurrent_Copy_Callback &); - PICurrent_Copy_Callback &operator= (const PICurrent_Copy_Callback &); - - /// Source PICurrent from which copies will be made. - PICurrent_Impl * src_; - - /// Destination PICurrent to which copies will be made. - PICurrent_Impl * dst_; - - }; -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#endif /* TAO_HAS_INTERCEPTORS == 1 */ - -#include /**/ "ace/post.h" - -#endif /* TAO_PI_CURRENT_CALLBACK_H */ diff --git a/TAO/tao/PI/PICurrent_Impl.cpp b/TAO/tao/PI/PICurrent_Impl.cpp index 4aa071e258c..7cb54b6df2c 100644 --- a/TAO/tao/PI/PICurrent_Impl.cpp +++ b/TAO/tao/PI/PICurrent_Impl.cpp @@ -11,8 +11,6 @@ ACE_RCSID (tao, # include "tao/PI/PICurrent_Impl.inl" #endif /* __ACE_INLINE__ */ -#include "tao/PI/PICurrent_Copy_Callback.h" - #include "tao/TAO_Server_Request.h" #include "tao/SystemException.h" #include "ace/Log_Msg.h" @@ -20,24 +18,6 @@ ACE_RCSID (tao, TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO::PICurrent_Impl::PICurrent_Impl (void) - : slot_table_ (), - lc_slot_table_ (0), - copy_callback_ (0), - destruction_callback_ (0) -{ -} - -TAO::PICurrent_Impl::~PICurrent_Impl (void) -{ - // Break any existing ties with PICurrent to which our table was - // logically copied since our table no longer exists once this - // destructor completes. - if (this->destruction_callback_ != 0) - this->destruction_callback_->execute_destruction_callback (0); -} - - CORBA::Any * TAO::PICurrent_Impl::get_slot (PortableInterceptor::SlotId identifier ACE_ENV_ARG_DECL) @@ -47,17 +27,17 @@ TAO::PICurrent_Impl::get_slot (PortableInterceptor::SlotId identifier // No need to check validity of SlotId. It is validated before this // method is invoked. - // Get the slot table that is currently active - PICurrent_Impl::Table & table = this->current_slot_table (); - // The active slot table should never be a lazy copy of itself! - if (this->lc_slot_table_ == &this->slot_table_) + if ( (0 != this->lazy_copy_) + && (&this->lazy_copy_->current_slot_table () == &this->slot_table_)) { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Lazy copy of self detected at %N,%l"))); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Lazy copy of self detected at %N,%l\n"))); ACE_THROW (CORBA::INTERNAL ()); } + // Get the slot table that is currently active + PICurrent_Impl::Table & table = this->current_slot_table (); CORBA::Any * any = 0; if (identifier < table.size ()) @@ -99,21 +79,14 @@ TAO::PICurrent_Impl::set_slot (PortableInterceptor::SlotId identifier, // No need to check validity of SlotId. It is validated before this // method is invoked. - // Perform deep copy of the logically copied slot table, if - // necessary, before modifying our own slot table. This is a setup - // where another PICurrent refers to our slot table, so we force the - // the other PICurrent does copy our table before making changes to - // our table. - if (this->copy_callback_ != 0) - this->copy_callback_->execute (); - - // If we have a logical copied slot table we refer to, just make a - // copy of that table first before making changes to our table. - if (this->lc_slot_table_ != 0) - { - this->slot_table_ = *this->lc_slot_table_; - this->lc_slot_table_ = 0; - } + // Break any existing ties that another PICurrent has with our table + // since our table is changing. + if (0 != this->impending_change_callback_) + this->impending_change_callback_->convert_from_lazy_to_real_copy (); + + // Ensure that we have a real physical copy of the table before + // making any changes to it. + this->convert_from_lazy_to_real_copy (); // If the slot table array isn't large enough, then increase its // size. We're guaranteed not to exceed the number of allocated @@ -126,16 +99,41 @@ TAO::PICurrent_Impl::set_slot (PortableInterceptor::SlotId identifier, } void -TAO::PICurrent_Impl::execute_destruction_callback ( - TAO::PICurrent_Impl::Table * old_lc_slot_table) +TAO::PICurrent_Impl::take_lazy_copy ( + TAO::PICurrent_Impl * p) { - // we are being asked to lc another table, if this - // is null, make sure we take a physical copy of the - // existing table we had lc before it disappears. - if ((0 == old_lc_slot_table) && (0 != this->lc_slot_table_)) - this->slot_table_ = *this->lc_slot_table_; - - this->lc_slot_table_ = old_lc_slot_table; + // Check that we are being told to actually change which table we are + // copying from. (If it is the same as before OR it would ultimately be + // the same table, we are already correctly setup and we do nothing.) + if ( (p != this->lazy_copy_) + && ((0 == p) || (&p->current_slot_table () != &this->current_slot_table ())) + ) + { + // Break any existing ties that another PICurrent has with our table + // since our table is changing. + if (0 != this->impending_change_callback_) + this->impending_change_callback_->convert_from_lazy_to_real_copy (); + + // If we have previously logically copied another table, ensure it is + // told that we are no longer interested in it so that it will not + // call our conver_from_lazy_to_real_copy() when it changes/destructs. + if (0 != this->lazy_copy_) + this->lazy_copy_->set_callback_for_impending_change (0); + + // Are we being asked to copy ourself (or nothing) + if ((0 == p) || (this == p)) + { + this->lazy_copy_ = 0; // Use our own physical slot_table_ + } + else + { + this->lazy_copy_ = p; + + // Must tell the newly copied PICurrent_Impl that we want to + // be told when/if it is going to be changed or destroyed. + this->lazy_copy_->set_callback_for_impending_change (this); + } + } } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PI/PICurrent_Impl.h b/TAO/tao/PI/PICurrent_Impl.h index b7d624a4c9b..11876b31acb 100644 --- a/TAO/tao/PI/PICurrent_Impl.h +++ b/TAO/tao/PI/PICurrent_Impl.h @@ -37,9 +37,6 @@ class TAO_ORB_Core; namespace TAO { - class PICurrent_Copy_Callback; - class PICurrent_Impl; - /** * @class PICurrent_Impl * @@ -53,10 +50,6 @@ namespace TAO class TAO_PI_Export PICurrent_Impl { public: - - /// Typedef for the underyling "slot table." - typedef ACE_Array_Base<CORBA::Any> Table; - /// Constructor. PICurrent_Impl (void); @@ -77,19 +70,23 @@ namespace TAO ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::InvalidSlot)); - /// Set the PICurrent copy callback object responsible for deep - /// copying the source PICurrent's slot table. - void copy_callback (PICurrent_Copy_Callback *cb); + /// Logically/Lazy (shallow) copy the given object's slot table. + void take_lazy_copy (PICurrent_Impl *p); - /// Set the PICurrent destruction callback object that will be - /// notified of this object's destruction. - void destruction_callback (PICurrent_Impl *p); + private: + /// Force this object to convert from a logical (referenced) + /// copy, to a physical (or deep, actual) copy. + void convert_from_lazy_to_real_copy (); - /// Execute the destruction callback object - void execute_destruction_callback (Table *old_lc_slot_table); + /// Set the callback PICurrent_Impl object that will be notified + /// of this object's impending destruction or change. + /// Set to 0 to clear. (NOTE Only handles a SINGLE object at + /// at time, does NOT warn previous callback that this has + /// been changed.) + void set_callback_for_impending_change (PICurrent_Impl *p); - /// Return a reference to the underlying slot table. - Table & slot_table (void); + /// Typedef for the underyling "slot table." + typedef ACE_Array_Base<CORBA::Any> Table; /// Return a reference to the slot table currently associated /// with this PICurrent_Impl object. @@ -97,20 +94,7 @@ namespace TAO * @return Logically copied slot table if available, otherwise * underlying slot table. */ - Table & current_slot_table (void); - - /// Logically (shallow) copy the given slot table. - // returns true if copied, false if it would be self-referencing. - bool lc_slot_table (PICurrent_Impl *p); - - /// Return pointer to the logically copied slot table. - /** - * @return Zero if no logically copied slot table. Non-zero - * otherwise. - */ - Table *lc_slot_table (void) const; - - private: + Table & current_slot_table (); /// Prevent copying through the copy constructor and the assignment /// operator. @@ -120,27 +104,19 @@ namespace TAO //@} private: - /// Array of CORBA::Anys that is the underlying "slot table." Table slot_table_; - /// Table that was logically copied from a PICurrent in another + /// Access to logical copy from a PICurrent_Impl in another /// scope, i.e. either the request scope or the thread scope. - Table *lc_slot_table_; - - /// Callback object responsible for performing deep copies of a - /// PICurrent's slot table. This is the PICurrent that has our slot_table_ - /// referred as lc_slot_table_. This copy is there to make sure that when - /// we want to modify our table, that we can first copy our table to - /// the PICurrent that refers to our table so that it has an unique copy - /// of the data. - PICurrent_Copy_Callback *copy_callback_; + PICurrent_Impl *lazy_copy_; /// PICurrent_Impl object that will be notified of this object's - /// destruction. This is the PICurrent that has our slot_table_ as - /// lc_slot_table_. - PICurrent_Impl *destruction_callback_; - + /// impending destruction or change to its slot_table_. This is + /// the PICurrent_Impl that has access to our slot_table_ via its + /// lazy_copy_ pointer. As necessary this allows that object's + /// convert_from_lazy_to_real_copy() to be called. + PICurrent_Impl *impending_change_callback_; }; } diff --git a/TAO/tao/PI/PICurrent_Impl.inl b/TAO/tao/PI/PICurrent_Impl.inl index 78c5e33cac6..eaedb899d20 100644 --- a/TAO/tao/PI/PICurrent_Impl.inl +++ b/TAO/tao/PI/PICurrent_Impl.inl @@ -4,67 +4,58 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_INLINE void -TAO::PICurrent_Impl::copy_callback (TAO::PICurrent_Copy_Callback *cb) -{ - this->copy_callback_ = cb; -} - -ACE_INLINE void -TAO::PICurrent_Impl::destruction_callback (TAO::PICurrent_Impl *p) -{ - this->destruction_callback_ = p; -} - -ACE_INLINE TAO::PICurrent_Impl::Table & -TAO::PICurrent_Impl::slot_table (void) +ACE_INLINE +TAO::PICurrent_Impl::PICurrent_Impl () + : slot_table_ (), + lazy_copy_ (0), + impending_change_callback_ (0) { - return this->slot_table_; } -ACE_INLINE TAO::PICurrent_Impl::Table & -TAO::PICurrent_Impl::current_slot_table (void) +ACE_INLINE +TAO::PICurrent_Impl::~PICurrent_Impl () { - return - this->lc_slot_table_ == 0 ? this->slot_table_ : *this->lc_slot_table_; + // Break any existing ties that another PICurrent has with our table + // since our table will no longer exist once this destructor completes. + if (0 != this->impending_change_callback_) + this->impending_change_callback_->convert_from_lazy_to_real_copy (); + + // If we have logically copied another table, ensure it is told about our + // demise so that it will not call our non-existant + // convert_from_lazy_to_real_copy() when it changes/destructs. + if (0 != this->lazy_copy_) + this->lazy_copy_->set_callback_for_impending_change (0); } -ACE_INLINE bool -TAO::PICurrent_Impl::lc_slot_table (TAO::PICurrent_Impl *p) +ACE_INLINE void +TAO::PICurrent_Impl::convert_from_lazy_to_real_copy () { - // Being told to lazy copy some other table? - if (p != 0) + // Make sure we take a physical copy of the existing logical + // copy of the table before it disappears/changes. + if (0 != this->lazy_copy_) { - // Which actual table are we supposed to lazy copy? - Table * t = &p->current_slot_table (); - - // Only if we have not already lazy copied this table - if (t != this->lc_slot_table_) - { - // Whould this be a lazy copy of ourselves? - if (t == &this->slot_table_) - this->lc_slot_table_ = 0; // Already ourself! - else - { - this->lc_slot_table_ = t; + this->slot_table_ = this->lazy_copy_->current_slot_table (); - // Ensure remote table will tell us if it is - // going to change or destroy itself. - if (this != p) - p->destruction_callback (this); - } - } + // Must tell the old copied PICurrent_Impl that we no + // longer want to be told when/if it is going to be + // changed or destroyed. + this->lazy_copy_->set_callback_for_impending_change (0); + this->lazy_copy_ = 0; } - else - this->lc_slot_table_ = 0; +} - return (0 != this->lc_slot_table_); +ACE_INLINE void +TAO::PICurrent_Impl::set_callback_for_impending_change (TAO::PICurrent_Impl *p) +{ + this->impending_change_callback_ = (this == p) ? 0 : p; } -ACE_INLINE TAO::PICurrent_Impl::Table * -TAO::PICurrent_Impl::lc_slot_table (void) const +ACE_INLINE TAO::PICurrent_Impl::Table & +TAO::PICurrent_Impl::current_slot_table () { - return this->lc_slot_table_; + return (0 == this->lazy_copy_) ? + this->slot_table_ : + this->lazy_copy_->current_slot_table (); } TAO_END_VERSIONED_NAMESPACE_DECL |