Stub.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // $Id: Stub.inl 81429 2008-04-24 18:49:54Z johnnyw $
00004 
00005 #include "tao/ORB_Core.h"
00006 
00007 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00008 
00009 ACE_INLINE void
00010 TAO_Stub::reset_base (void)
00011 {
00012   this->base_profiles_.rewind ();
00013   this->profile_success_ = false;
00014 
00015   this->set_profile_in_use_i (base_profiles_.get_next ());
00016 }
00017 
00018 
00019 ACE_INLINE ACE_Lock*
00020 TAO_Stub::profile_lock (void) const
00021 {
00022   return this->profile_lock_ptr_;
00023 }
00024 
00025 ACE_INLINE void
00026 TAO_Stub::reset_forward (void)
00027 {
00028   while (this->forward_profiles_ != 0
00029          && this->forward_profiles_ != this->forward_profiles_perm_) // Disturbingly the permanent
00030                                                                      // forwarded profile lives at the  bottom
00031                                                                      // of this stack if it exists. Avoid deleting it.
00032     this->forward_back_one ();
00033 }
00034 
00035 ACE_INLINE void
00036 TAO_Stub::reset_profiles_i (void)
00037 {
00038   this->reset_forward ();
00039   this->reset_base ();
00040 
00041   if (this->forward_profiles_perm_)
00042     {
00043       // The *permanent* forward is being kept in the transient
00044       // forward queue (??!). We have just nuked it. Put it back the way it was.
00045       // reset_base should have reset the profile success.
00046       // @todo We have knives in the spoon draw - TAO_Stub needs total rewrite.
00047       this->forward_profiles_ = this->forward_profiles_perm_;
00048       this->forward_profiles_->rewind ();
00049       this->set_profile_in_use_i (this->forward_profiles_->get_next ());
00050     }
00051 }
00052 
00053 ACE_INLINE void
00054 TAO_Stub::reset_profiles (void)
00055 {
00056   ACE_MT (ACE_GUARD (ACE_Lock,
00057                      guard,
00058                      *this->profile_lock_ptr_));
00059   this->reset_profiles_i ();
00060 }
00061 
00062 ACE_INLINE TAO_Profile *
00063 TAO_Stub::profile_in_use (void)
00064 {
00065   return this->profile_in_use_;
00066 }
00067 
00068 ACE_INLINE TAO_MProfile *
00069 TAO_Stub::make_profiles (void)
00070 {
00071   TAO_MProfile *mp = 0;
00072 
00073   ACE_NEW_RETURN (mp,
00074                   TAO_MProfile (base_profiles_),
00075                   0);
00076 
00077   return mp;
00078 }
00079 
00080 ACE_INLINE TAO_Profile *
00081 TAO_Stub::next_forward_profile (void)
00082 {
00083   TAO_Profile *pfile_next = 0;
00084 
00085   while (this->forward_profiles_
00086          && (pfile_next = this->forward_profiles_->get_next ()) == 0
00087          && this->forward_profiles_ != this->forward_profiles_perm_)  // do not remove permanent forward from bottom of stack
00088     // that was the last profile.  Now we clean up our forward profiles.
00089     // since we own the forward MProfiles, we must delete them when done.
00090     this->forward_back_one ();
00091 
00092   return pfile_next;
00093 }
00094 
00095 ACE_INLINE TAO_Profile *
00096 TAO_Stub::next_profile_i (void)
00097 {
00098   TAO_Profile *pfile_next = 0;
00099 
00100   // First handle the case that a permanent forward occured
00101   if (this->forward_profiles_perm_) // the permanent forward defined
00102                                     // at bottom of stack
00103                                     // forward_profiles_
00104     {
00105       // In case of permanent forward the base_profiles are ingored.
00106 
00107       pfile_next = this->next_forward_profile ();
00108 
00109       if (pfile_next == 0)
00110         {
00111           // COND: this->forward_profiles_ == this->forward_profiles_perm_
00112 
00113           // reached end of list of permanent forward profiles
00114           // now, reset forward_profiles_perm_
00115 
00116           this->forward_profiles_->rewind ();
00117           this->profile_success_ = false;
00118           this->set_profile_in_use_i (this->forward_profiles_->get_next());
00119         }
00120       else
00121         this->set_profile_in_use_i (pfile_next);
00122 
00123       // We may have been forwarded to / from a collocated situation
00124       // Check for this and apply / remove optimisation if required.
00125       this->orb_core_->reinitialize_object (this);
00126 
00127       return pfile_next;
00128     }
00129   else
00130     {
00131       if (this->forward_profiles_) // Now do the common operation
00132         {
00133           pfile_next = this->next_forward_profile ();
00134           if (pfile_next == 0)
00135             {
00136               // Fall back to base profiles
00137               pfile_next = this->base_profiles_.get_next ();
00138             }
00139 
00140           // We may have been forwarded to / from a collocated situation
00141           // Check for this and apply / remove optimisation if required.
00142           this->orb_core_->reinitialize_object (this);
00143         }
00144       else
00145         pfile_next = this->base_profiles_.get_next ();
00146 
00147       if (pfile_next == 0)
00148         this->reset_base ();
00149       else
00150         this->set_profile_in_use_i (pfile_next);
00151 
00152       return pfile_next;
00153    }
00154 }
00155 
00156 ACE_INLINE TAO_Profile *
00157 TAO_Stub::next_profile (void)
00158 {
00159   ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
00160                             guard,
00161                             *this->profile_lock_ptr_,
00162                             0));
00163   return this->next_profile_i ();
00164 }
00165 
00166 ACE_INLINE CORBA::Boolean
00167 TAO_Stub::valid_forward_profile (void)
00168 {
00169   return (this->profile_success_ && this->forward_profiles_);
00170 }
00171 
00172 ACE_INLINE void
00173 TAO_Stub::set_valid_profile (void)
00174 {
00175   this->profile_success_ = true;
00176 }
00177 
00178 ACE_INLINE CORBA::Boolean
00179 TAO_Stub::valid_profile (void) const
00180 {
00181   return this->profile_success_;
00182 }
00183 
00184 ACE_INLINE TAO_Profile *
00185 TAO_Stub::base_profiles (const TAO_MProfile &mprofiles)
00186 {
00187   ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
00188                             guard,
00189                             *this->profile_lock_ptr_,
00190                             0));
00191 
00192   // first reset things so we start from scratch!
00193 
00194   // @note This reset forward could effect the collocation status
00195   // but as this method is only used from the Stub ctr, when the status
00196   // is already correctly set, we don't reinitialise here. sm.
00197   this->reset_forward ();
00198   this->base_profiles_.set (mprofiles);
00199   this->reset_base ();
00200   return this->profile_in_use_;
00201 
00202 }
00203 
00204 ACE_INLINE CORBA::Boolean
00205 TAO_Stub::next_profile_retry (void)
00206 {
00207   ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
00208                             guard,
00209                             *this->profile_lock_ptr_,
00210                             0));
00211 
00212   if (this->profile_success_ && this->forward_profiles_)
00213     {
00214       // We have a forwarded reference that we have managed to *send* a message to
00215       // previously in the remote path only (but not counting object proxy broker ops).
00216       // @todo I can see little sense to this. It is at best highly inconsistent. sm.
00217 
00218       // In this case we are falling back from the forwarded IOR stright to the base IOR
00219       this->reset_profiles_i ();
00220 
00221       // We used to return unconditional true at this point but this results in
00222       // infinite retries of any permanent location forward. This is undesirable.
00223       return !this->forward_profiles_perm_;
00224     }
00225   else if (this->next_profile_i ())
00226     {
00227       return true;
00228     }
00229 
00230   return false;
00231 }
00232 
00233 ACE_INLINE const TAO_MProfile&
00234 TAO_Stub::base_profiles (void) const
00235 {
00236   return this->base_profiles_;
00237 }
00238 
00239 ACE_INLINE TAO_MProfile&
00240 TAO_Stub::base_profiles (void)
00241 {
00242   return this->base_profiles_;
00243 }
00244 
00245 ACE_INLINE const TAO_MProfile *
00246 TAO_Stub::forward_profiles (void) const
00247 {
00248   return this->forward_profiles_;
00249 }
00250 
00251 ACE_INLINE CORBA::Boolean
00252 TAO_Stub::is_collocated (void) const
00253 {
00254   return this->is_collocated_;
00255 }
00256 
00257 ACE_INLINE TAO_ORB_Core*
00258 TAO_Stub::orb_core (void) const
00259 {
00260   return this->orb_core_.get ();
00261 }
00262 
00263 ACE_INLINE CORBA::ORB_var &
00264 TAO_Stub::servant_orb_var (void)
00265 {
00266   // Simply pass back the ORB pointer for temporary use.
00267   return this->servant_orb_;
00268 }
00269 
00270 ACE_INLINE CORBA::ORB_ptr
00271 TAO_Stub::servant_orb_ptr (void)
00272 {
00273   // Simply pass back the ORB pointer for temporary use.
00274   return CORBA::ORB::_duplicate (this->servant_orb_.in ());
00275 }
00276 
00277 ACE_INLINE void
00278 TAO_Stub::servant_orb (CORBA::ORB_ptr orb)
00279 {
00280   this->servant_orb_ = CORBA::ORB::_duplicate (orb);
00281 }
00282 
00283 ACE_INLINE TAO_Abstract_ServantBase *
00284 TAO_Stub::collocated_servant (void) const
00285 {
00286   return collocated_servant_;
00287 }
00288 
00289 ACE_INLINE void
00290 TAO_Stub::collocated_servant (TAO_Abstract_ServantBase * servant)
00291 {
00292   this->collocated_servant_ = servant;
00293 }
00294 
00295 ACE_INLINE TAO::Object_Proxy_Broker *
00296 TAO_Stub::object_proxy_broker (void) const
00297 {
00298   return this->object_proxy_broker_;
00299 }
00300 
00301 ACE_INLINE void
00302 TAO_Stub::object_proxy_broker (TAO::Object_Proxy_Broker * object_proxy_broker)
00303 {
00304   this->object_proxy_broker_ = object_proxy_broker;
00305 }
00306 
00307 ACE_INLINE void
00308 TAO_Stub::destroy (void)
00309 {
00310   // The reference count better be zero at this point!
00311   delete this;
00312 }
00313 
00314 ACE_INLINE CORBA::Boolean
00315 TAO_Stub::optimize_collocation_objects (void) const
00316 {
00317   return this->collocation_opt_;
00318 }
00319 
00320 ACE_INLINE TAO::Transport_Queueing_Strategy *
00321 TAO_Stub::transport_queueing_strategy (void)
00322 {
00323 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00324 
00325   bool has_synchronization;
00326   Messaging::SyncScope scope;
00327 
00328   this->orb_core_->call_sync_scope_hook (this, has_synchronization, scope);
00329 
00330   if (has_synchronization == true)
00331     return this->orb_core_->get_transport_queueing_strategy  (this, scope);
00332 #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */
00333 
00334   // No queueing strategy, let the transport use its default
00335   return 0;
00336 }
00337 
00338 // ---------------------------------------------------------------
00339 
00340 // Creator methods for TAO_Stub_Auto_Ptr (TAO_Stub Auto Pointer)
00341 ACE_INLINE
00342 TAO_Stub_Auto_Ptr::TAO_Stub_Auto_Ptr (TAO_Stub *p)
00343   : p_ (p)
00344 {
00345   ACE_TRACE ("TAO_Stub_Auto_Ptr::TAO_Stub_Auto_Ptr");
00346 }
00347 
00348 ACE_INLINE TAO_Stub *
00349 TAO_Stub_Auto_Ptr::get (void) const
00350 {
00351   ACE_TRACE ("TAO_Stub_Auto_Ptr::get");
00352   return this->p_;
00353 }
00354 
00355 ACE_INLINE TAO_Stub *
00356 TAO_Stub_Auto_Ptr::release (void)
00357 {
00358   ACE_TRACE ("TAO_Stub_Auto_Ptr::release");
00359   TAO_Stub *old = this->p_;
00360   this->p_ = 0;
00361   return old;
00362 }
00363 
00364 ACE_INLINE void
00365 TAO_Stub_Auto_Ptr::reset (TAO_Stub *p)
00366 {
00367   ACE_TRACE ("TAO_Stub_Auto_Ptr::reset");
00368   if (this->get () != p && this->get () != 0)
00369     this->get ()->_decr_refcnt ();
00370   this->p_ = p;
00371 }
00372 
00373 ACE_INLINE TAO_Stub *
00374 TAO_Stub_Auto_Ptr::operator-> () const
00375 {
00376   ACE_TRACE ("TAO_Stub_Auto_Ptr::operator->");
00377   return this->get ();
00378 }
00379 
00380 ACE_INLINE
00381 TAO_Stub_Auto_Ptr::TAO_Stub_Auto_Ptr (TAO_Stub_Auto_Ptr &rhs)
00382   : p_ (rhs.release ())
00383 {
00384   ACE_TRACE ("TAO_Stub_Auto_Ptr::TAO_Stub_Auto_Ptr");
00385 }
00386 
00387 ACE_INLINE TAO_Stub_Auto_Ptr &
00388 TAO_Stub_Auto_Ptr::operator= (TAO_Stub_Auto_Ptr &rhs)
00389 {
00390   ACE_TRACE ("TAO_Stub_Auto_Ptr::operator=");
00391   if (this != &rhs)
00392     {
00393       this->reset (rhs.release ());
00394     }
00395   return *this;
00396 }
00397 
00398 ACE_INLINE
00399 TAO_Stub_Auto_Ptr::~TAO_Stub_Auto_Ptr (void)
00400 {
00401   ACE_TRACE ("TAO_Stub_Auto_Ptr::~TAO_Stub_Auto_Ptr");
00402   if (this->get() != 0)
00403     this->get ()->_decr_refcnt ();
00404 }
00405 
00406 // Accessor methods to the underlying Stub Object
00407 
00408 ACE_INLINE TAO_Stub &
00409 TAO_Stub_Auto_Ptr::operator *() const
00410 {
00411   ACE_TRACE ("TAO_Stub_Auto_Ptr::operator *()");
00412   // @@ Potential problem if this->p_ is zero!
00413   return *this->get ();
00414 }
00415 
00416 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7