Wait_On_LF_No_Upcall.cpp

Go to the documentation of this file.
00001 // $Id: Wait_On_LF_No_Upcall.cpp 76687 2007-01-29 19:18:13Z johnnyw $
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           "$Id: Wait_On_LF_No_Upcall.cpp 76687 2007-01-29 19:18:13Z johnnyw $")
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 = t_->orb_core ()->get_tss_resources ();
00048 
00049       tss->upcalls_temporarily_suspended_on_this_thread_ = false;
00050 
00051       if (TAO_debug_level > 6)
00052         {
00053           ACE_DEBUG ((LM_DEBUG,
00054                       "TAO (%P|%t) - Wait_On_LF_No_Upcall::wait "
00055                       "re-enabling upcalls on thread %t\n"));
00056         }
00057     }
00058 
00059   private:
00060 
00061     Nested_Upcall_Guard (void)
00062     {
00063     }
00064 
00065     /// Disallow copying and assignment.
00066     Nested_Upcall_Guard (const Nested_Upcall_Guard&);
00067     Nested_Upcall_Guard &operator= (const Nested_Upcall_Guard&);
00068 
00069   private:
00070 
00071     /// Pointer to the transport that we plan to use.
00072     TAO_Transport *t_;
00073   };
00074 
00075 
00076   //=================================================================
00077 
00078   Wait_On_LF_No_Upcall::Wait_On_LF_No_Upcall (TAO_Transport *t)
00079     : base (t)
00080   {
00081   }
00082 
00083   Wait_On_LF_No_Upcall::~Wait_On_LF_No_Upcall (void)
00084   {
00085   }
00086 
00087   int
00088   Wait_On_LF_No_Upcall::wait (ACE_Time_Value *max_wait_time,
00089                               TAO_Synch_Reply_Dispatcher &rd)
00090   {
00091     Nested_Upcall_Guard upcall_guard (this->transport_);
00092 
00093     return base::wait (max_wait_time, rd);
00094   }
00095 
00096   bool
00097   Wait_On_LF_No_Upcall::can_process_upcalls (void) const
00098   {
00099     TAO_ORB_Core_TSS_Resources *tss =
00100       this->transport_->orb_core ()->get_tss_resources ();
00101 
00102     if ((this->transport_->opened_as () == TAO::TAO_CLIENT_ROLE) &&
00103         (this->transport_->bidirectional_flag () == 0) &&
00104         (tss->upcalls_temporarily_suspended_on_this_thread_ == true))
00105       return false;
00106 
00107     return true;
00108   }
00109 }
00110 
00111 TAO_END_VERSIONED_NAMESPACE_DECL

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