00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file CSD_TP_Request.h 00006 * 00007 * $Id: CSD_TP_Request.h 80158 2007-12-02 16:12:30Z sowayaa $ 00008 * 00009 * @author Tim Bradley <bradley_t@ociweb.com> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_CSD_TP_REQUEST_H 00014 #define TAO_CSD_TP_REQUEST_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "tao/CSD_ThreadPool/CSD_TP_Export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "tao/CSD_ThreadPool/CSD_TP_Servant_State.h" 00025 #include "tao/PortableServer/Servant_Base.h" 00026 #include "tao/Intrusive_Ref_Count_Base_T.h" 00027 #include "tao/Intrusive_Ref_Count_Handle_T.h" 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 namespace TAO 00032 { 00033 namespace CSD 00034 { 00035 00036 class TP_Request; 00037 typedef TAO_Intrusive_Ref_Count_Handle<TP_Request> TP_Request_Handle; 00038 00039 class TP_Queue; 00040 00041 00042 /** 00043 * @class TP_Request 00044 * 00045 * @brief Base class for "queue-able" requests. 00046 * 00047 * This class serves as the abstract base class for all types of 00048 * "servant requests" that can be inserted into a TP_Queue 00049 * object. 00050 */ 00051 class TAO_CSD_TP_Export TP_Request 00052 : public TAO_Intrusive_Ref_Count_Base<TAO_SYNCH_MUTEX> 00053 { 00054 public: 00055 00056 /// Virtual Destructor. 00057 virtual ~TP_Request(); 00058 00059 /// Prepare the request to be placed into the request queue. 00060 void prepare_for_queue(); 00061 00062 /// Invoked to dispatch the request to the servant. 00063 void dispatch(); 00064 00065 /// Invoked to cancel the request. 00066 void cancel(); 00067 00068 /// Is the target servant ready to accept a request? 00069 bool is_ready() const; 00070 00071 /// Mark the target servant as being busy. 00072 void mark_as_busy(); 00073 00074 /// Mark the target servant as being ready (ie, not busy). 00075 void mark_as_ready(); 00076 00077 /// This method returns true if this request targets the supplied 00078 /// servant object. 00079 bool is_target(PortableServer::Servant servant); 00080 00081 00082 protected: 00083 00084 /// Constructor. 00085 TP_Request(PortableServer::Servant servant, 00086 TP_Servant_State* servant_state); 00087 00088 /// Accessor for the servant. Does not return a new (ref counted) 00089 /// reference! This is used for chaining. 00090 PortableServer::Servant servant(); 00091 00092 /// The subclass knows if it needs to do anything in preparation 00093 /// of being placed into the request queue. The default implementation 00094 /// does nothing, so only subclasses that have something to do 00095 /// need to provide their own implementation. 00096 virtual void prepare_for_queue_i(); 00097 00098 /// The subclass knows how to carry out its own way of dispatching 00099 /// the request to the servant. 00100 virtual void dispatch_i() = 0; 00101 00102 /// Ask the subclass to perform its duties to carry out the cancellation. 00103 virtual void cancel_i() = 0; 00104 00105 00106 private: 00107 00108 /// The TP_Queue class is our friend since it needs access to 00109 /// the prev_ and next_ (private) data members. 00110 friend class TP_Queue; 00111 00112 /// The previous TP_Request object (in the queue). 00113 TP_Request* prev_; 00114 00115 /// The next TP_Request object (in the queue). 00116 TP_Request* next_; 00117 00118 /// Reference to the servant object. 00119 PortableServer::ServantBase_var servant_; 00120 00121 /// Reference to the servant "state" object (contains the busy flag). 00122 TP_Servant_State::HandleType servant_state_; 00123 }; 00124 00125 } 00126 } 00127 00128 TAO_END_VERSIONED_NAMESPACE_DECL 00129 00130 #if defined (__ACE_INLINE__) 00131 # include "tao/CSD_ThreadPool/CSD_TP_Request.inl" 00132 #endif /* __ACE_INLINE__ */ 00133 00134 #include /**/ "ace/post.h" 00135 00136 #endif /* TAO_CSD_TP_REQUEST_H */