00001 // Wait_On_LF_No_Upcall.cpp,v 1.8 2006/03/10 07:19:07 jtc Exp 00002 00003 #include "tao/Wait_On_LF_No_Upcall.h" 00004 00005 #include "tao/Transport.h" 00006 #include "tao/ORB_Core.h" 00007 #include "tao/ORB_Core_TSS_Resources.h" 00008 #include "tao/debug.h" 00009 00010 ACE_RCSID(tao, 00011 Wait_On_LF_No_Upcall, 00012 "Wait_On_LF_No_Upcall.cpp,v 1.8 2006/03/10 07:19:07 jtc Exp") 00013 00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00015 00016 class TAO_Transport; 00017 namespace TAO 00018 { 00019 /** 00020 * @class Nested_Upcall_Guard 00021 * 00022 * @brief: Magic class that sets the status of the thread in the 00023 * TSS. 00024 * 00025 */ 00026 class Nested_Upcall_Guard 00027 { 00028 public: 00029 // Maybe we should instead just take in a ptr to 00030 // TAO_ORB_Core_TSS_Resources? Or at least ORB_Core*? 00031 Nested_Upcall_Guard (TAO_Transport* t) 00032 : t_ (t) 00033 { 00034 TAO_ORB_Core_TSS_Resources *tss = 00035 t_->orb_core()->get_tss_resources (); 00036 00037 tss->upcalls_temporarily_suspended_on_this_thread_ = true; 00038 00039 if (TAO_debug_level > 6) 00040 ACE_DEBUG ((LM_DEBUG, 00041 "TAO (%P|%t) - Wait_On_LF_No_Upcall::wait " 00042 "disabling upcalls on thread %t\n")); 00043 } 00044 00045 ~Nested_Upcall_Guard (void) 00046 { 00047 TAO_ORB_Core_TSS_Resources *tss = 00048 t_->orb_core()->get_tss_resources (); 00049 00050 tss->upcalls_temporarily_suspended_on_this_thread_ = 00051 false; 00052 00053 if (TAO_debug_level > 6) 00054 ACE_DEBUG ((LM_DEBUG, 00055 "TAO (%P|%t) - Wait_On_LF_No_Upcall::wait " 00056 "re-enabling upcalls on thread %t\n")); 00057 } 00058 00059 private: 00060 00061 Nested_Upcall_Guard (void) {} 00062 00063 /// Disallow copying and assignment. 00064 Nested_Upcall_Guard (const Nested_Upcall_Guard&); 00065 Nested_Upcall_Guard & operator= (const Nested_Upcall_Guard&); 00066 00067 private: 00068 00069 /// Pointer to the transport that we plan to use. 00070 TAO_Transport* t_; 00071 }; 00072 00073 00074 //================================================================= 00075 00076 Wait_On_LF_No_Upcall::Wait_On_LF_No_Upcall (TAO_Transport *t) 00077 : base (t) 00078 { 00079 } 00080 00081 Wait_On_LF_No_Upcall::~Wait_On_LF_No_Upcall (void) 00082 { 00083 } 00084 00085 int 00086 Wait_On_LF_No_Upcall::wait (ACE_Time_Value *max_wait_time, 00087 TAO_Synch_Reply_Dispatcher &rd) 00088 { 00089 Nested_Upcall_Guard upcall_guard (this->transport_); 00090 00091 return base::wait (max_wait_time, rd); 00092 } 00093 00094 bool 00095 Wait_On_LF_No_Upcall::can_process_upcalls (void) const 00096 { 00097 TAO_ORB_Core_TSS_Resources *tss = 00098 this->transport_->orb_core()->get_tss_resources (); 00099 00100 if ((this->transport_->opened_as () == TAO::TAO_CLIENT_ROLE) && 00101 (this->transport_->bidirectional_flag () == 0) && 00102 (tss->upcalls_temporarily_suspended_on_this_thread_ == true)) 00103 return false; 00104 00105 return true; 00106 } 00107 } 00108 00109 TAO_END_VERSIONED_NAMESPACE_DECL