summaryrefslogtreecommitdiff
path: root/TAO/tao/Stub.i
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/Stub.i')
-rw-r--r--TAO/tao/Stub.i353
1 files changed, 195 insertions, 158 deletions
diff --git a/TAO/tao/Stub.i b/TAO/tao/Stub.i
index 242203aaba2..16bd60e024a 100644
--- a/TAO/tao/Stub.i
+++ b/TAO/tao/Stub.i
@@ -5,19 +5,49 @@
#include <tao/debug.h>
ACE_INLINE
+STUB_Object::~STUB_Object (void)
+{
+ assert (this->refcount_ == 0);
+
+ // Cleanup hint
+
+ if (this->profile_in_use_ != 0)
+ {
+ this->profile_in_use_->reset_hint ();
+ // decrease reference count on profile
+ this->profile_in_use_->_decr_refcnt ();
+ this->profile_in_use_ = 0;
+ }
+
+ if (this->fwd_profile_)
+ {
+ this->fwd_profile_->reset_hint ();
+ this->fwd_profile_->_decr_refcnt ();
+ this->fwd_profile_ = 0;
+ }
+
+ if (fwd_profiles_)
+ delete fwd_profiles_;
+
+ if (this->profile_lock_ptr_)
+ delete this->profile_lock_ptr_;
+
+}
+
+ACE_INLINE
TAO_Profile *
-TAO_Stub::set_profile_in_use_i (TAO_Profile *pfile)
+STUB_Object::set_profile_in_use_i (TAO_Profile *pfile)
{
TAO_Profile *old = this->profile_in_use_;
// Since we are actively using this profile we dont want
// it to disappear, so increase the reference count by one!!
if (pfile && (pfile->_incr_refcnt () == 0))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) unable to increment profile ref!\n"),
- 0);
- }
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) unable to increment profile ref!\n"),
+ 0);
+ }
this->profile_in_use_ = pfile;
@@ -28,245 +58,252 @@ TAO_Stub::set_profile_in_use_i (TAO_Profile *pfile)
}
ACE_INLINE
-void
-TAO_Stub::reset_first_locate_request (void)
+TAO_Profile *
+STUB_Object::set_profiles (TAO_MProfile *mprofiles)
{
- first_locate_request_ = 1;
+
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
+ 0));
+
+ base_profiles_.set (mprofiles);
+
+ return this->set_profile_in_use_i (this->base_profiles_.get_next ());
+
}
ACE_INLINE
-void
-TAO_Stub::reset_base (void)
+TAO_Profile *
+STUB_Object::profile_in_use (void)
{
- this->base_profiles_.rewind ();
- reset_first_locate_request ();
- profile_success_ = 0;
-
- set_profile_in_use_i (base_profiles_.get_next ());
+ return this->profile_in_use_;
}
ACE_INLINE
-void
-TAO_Stub::forward_back_one (void)
+TAO_Profile *
+STUB_Object::set_profile_in_use (TAO_Profile *pfile)
{
- TAO_MProfile *from = forward_profiles_->forward_from ();
- delete forward_profiles_;
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
+ 0));
- // the current profile in this profile list is no
- // longer being forwarded, so set the reference to zero.
- if (from == &base_profiles_)
- {
- base_profiles_.get_current_profile ()->forward_to (0);
- forward_profiles_ = 0;
- }
- else
- {
- from->get_current_profile ()->forward_to (0);
- forward_profiles_ = from;
- }
+ return set_profile_in_use_i (pfile);
}
-ACE_INLINE
-void
-TAO_Stub::reset_forward (void)
-{
- while (this->forward_profiles_ != 0)
- forward_back_one ();
-}
ACE_INLINE
-void
-TAO_Stub::reset_profiles_i (void)
+TAO_Profile *
+STUB_Object::get_fwd_profile_i (void)
{
- reset_forward ();
- reset_base ();
+ return this->fwd_profile_;
}
ACE_INLINE
-void
-TAO_Stub::reset_profiles (void)
+TAO_Profile *
+STUB_Object::get_fwd_profile (void)
{
- ACE_MT (ACE_GUARD (ACE_Lock,
- guard,
- *this->profile_lock_ptr_));
- reset_profiles_i ();
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
+ 0));
+
+ return this->get_fwd_profile_i ();
}
+
+// set_fwd_profile is currently called with either an arg of NULL
+// or with a pointer to another STUB_Object's profile_in_use_.
+// Change in strategy from previous version: Since we assume this
+// forward profile comes from am MProfile list, we just increment the
+// reference count on the profile. We do not copy it and we assume
+// the user will not modify!
ACE_INLINE
-TAO_Stub::~TAO_Stub (void)
+TAO_Profile *
+STUB_Object::set_fwd_profile (TAO_Profile *new_profile)
{
- assert (this->refcount_ == 0);
+
+ TAO_Profile *old = this->fwd_profile_;
- if (forward_profiles_)
- reset_profiles ();
+ // show that we are using this!
+ // @@ could be an inline => reduce code, common
+ if (new_profile && (new_profile->_incr_refcnt () == 0))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) unable to increment profile ref!\n"),
+ 0);
+ }
- if (this->profile_in_use_ != 0)
- {
- this->profile_in_use_->reset_hint ();
- // decrease reference count on profile
- this->profile_in_use_->_decr_refcnt ();
- this->profile_in_use_ = 0;
- }
+ this->fwd_profile_ = new_profile;
- if (this->profile_lock_ptr_)
- delete this->profile_lock_ptr_;
+ if (old)
+ old->_decr_refcnt ();
+ return this->fwd_profile_;
}
ACE_INLINE
-TAO_Profile *
-TAO_Stub::profile_in_use (void)
+ACE_Lock &
+STUB_Object::get_profile_lock (void)
{
- return this->profile_in_use_;
+ return *this->profile_lock_ptr_;
}
ACE_INLINE
-void
-TAO_Stub::use_locate_requests (CORBA::Boolean use_it)
+void
+STUB_Object::reset_first_locate_request (void)
+{
+ first_locate_request_ = 1;
+}
+
+ACE_INLINE
+void
+STUB_Object::use_locate_requests (CORBA::Boolean use_it)
{
if (use_it)
{
this->first_locate_request_ = 1;
this->use_locate_request_ = 1;
}
- else
+ else
{
// Don't use it.
this->first_locate_request_ = 0;
this->use_locate_request_ = 0;
- }
-}
+ }
+}
ACE_INLINE
-TAO_MProfile *
-TAO_Stub::get_profiles (void)
+TAO_MProfile *
+STUB_Object::get_profiles (void)
{
- return new TAO_MProfile (base_profiles_);
+ return new TAO_MProfile (&base_profiles_);
}
ACE_INLINE
-TAO_Profile *
-TAO_Stub::next_forward_profile (void)
+void
+STUB_Object::reset_fwd_profiles (void)
{
- TAO_Profile *pfile_next = 0;
-
- while (this->forward_profiles_
- && (pfile_next = forward_profiles_->get_next ()) == 0)
- // that was the last profile. Now we clean up our forward profiles.
- // since we own the forward MProfiles, we must delete them when done.
- forward_back_one ();
- return pfile_next;
+ if (fwd_profiles_)
+ {
+ // @@ Assume on one level deep FRED
+ TAO_MProfile *old = fwd_profiles_;
+ TAO_MProfile *prev = old->fwded_mprofile ();
+ // this should be base_profiles_
+ if (prev->get_current_profile ())
+ prev->get_current_profile ()->fwd_profiles (0);
+ // it better be! this should be profile_in_use_
+ }
+
+ set_fwd_profile (0);
}
ACE_INLINE
TAO_Profile *
-TAO_Stub::next_profile_i (void)
+STUB_Object::reset_profiles (void)
{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
+ 0));
- TAO_Profile *pfile_next = 0;
- if (forward_profiles_)
- {
- pfile_next = next_forward_profile ();
- if (pfile_next == 0)
- pfile_next = base_profiles_.get_next ();
- }
- else
- pfile_next = base_profiles_.get_next ();
+ // first get rid of any forwarding profile list and fwd_profile
+ reset_fwd_profiles ();
- if (pfile_next == 0)
- reset_base ();
- else
- set_profile_in_use_i (pfile_next);
+ // then rewind profile list, back to the beginning
+ this->base_profiles_.rewind ();
- return pfile_next;
+ reset_first_locate_request ();
+ // resets the flag of the first call locate request to true
+
+ return this->set_profile_in_use_i (this->base_profiles_.get_next ());
}
ACE_INLINE
TAO_Profile *
-TAO_Stub::next_profile (void)
+STUB_Object::next_profile (void)
{
-
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
- guard,
- *this->profile_lock_ptr_,
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
0));
- return next_profile_i ();
+
+ return this->set_profile_in_use_i (this->base_profiles_.get_next ());
}
ACE_INLINE
-CORBA::Boolean
-TAO_Stub::valid_forward_profile (void)
+TAO_MProfile *
+STUB_Object::get_fwd_profiles (void)
{
- return (profile_success_ && forward_profiles_);
+ if (fwd_profiles_)
+ return new TAO_MProfile (this->fwd_profiles_);
+ return 0;
}
ACE_INLINE
void
-TAO_Stub::set_valid_profile (void)
+STUB_Object::set_fwd_profiles (TAO_MProfile *mprofiles)
{
- profile_success_ = 1;
-}
-ACE_INLINE
-CORBA::Boolean
-TAO_Stub::valid_profile (void)
-{
- return profile_success_;
-}
+ if (! profile_in_use_)
+ return ;
-ACE_INLINE
-TAO_Profile *
-TAO_Stub::set_base_profiles (const TAO_MProfile &mprofiles)
-{
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
- guard,
- *this->profile_lock_ptr_,
- 0));
+ // profile_in_use_ will copy the object but delegate
+ // to this Stub_Obj responsibility for manipulating list!
+ TAO_MProfile *tmp = new TAO_MProfile (mprofiles);
- // first reset things so we start from scratch!
- reset_forward ();
- base_profiles_.set (mprofiles);
- reset_base ();
- return profile_in_use_;
+ // now add a pointer back the the profile list hat had been
+ // forwarded. Note, since the profile list is like
+ // a state machine, the current poitner refers to the
+ // actual profile that was forwarded!
+ {
+ ACE_MT (ACE_GUARD (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_));
+
+ if (this->fwd_profiles_)
+ {
+ if (TAO_orbdebug)
+ ACE_DEBUG ((LM_DEBUG, "** Overwriting fwd profiles!\n"));
+ TAO_MProfile *old = this->fwd_profiles_;
+ TAO_MProfile *prev = old->fwded_mprofile ();
+ if (prev->get_current_profile ())
+ prev->get_current_profile ()->fwd_profiles (0);
+ // @@ FRED: UGLY but for now just one level!
+ delete this->fwd_profiles_;
+ }
+
+ this->fwd_profiles_ = tmp;
+
+ // @@ if (this->fwd_profiles_)
+ // @@ // add a link in the chain!
+ // @@ tmp->fwded_mprofile (this->fwd_profiles_);
+
+ this->fwd_profiles_->fwded_mprofile (&this->base_profiles_);
+ profile_in_use_->fwd_profiles (this->fwd_profiles_);
+
+ set_fwd_profile ( this->fwd_profiles_->get_next ());
+ }
+
}
ACE_INLINE
-CORBA::Boolean
-TAO_Stub::next_profile_retry (void)
+TAO_Profile *
+STUB_Object::next_fwd_profile (void)
{
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
- guard,
- *this->profile_lock_ptr_,
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
0));
- if (profile_success_ && forward_profiles_)
- {
- reset_profiles_i ();
- return 1;
- }
- else if (next_profile_i ())
- {
- return 1;
- }
- else
- {
- reset_profiles_i ();
- return 0;
- }
-}
+ if (fwd_profiles_)
+ return this->set_fwd_profile (this->fwd_profiles_->get_next ());
-ACE_INLINE const TAO_MProfile&
-TAO_Stub::get_base_profiles (void) const
-{
- return this->base_profiles_;
+ return this->set_fwd_profile (0);
}
-ACE_INLINE TAO_ORB_Core*
-TAO_Stub::orb_core (void) const
-{
- return this->orb_core_;
-}