00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file CSD_TP_Queue.h 00006 * 00007 * $Id: CSD_TP_Queue.h 71473 2006-03-10 07:19:20Z jtc $ 00008 * 00009 * @author Tim Bradley <bradley_t@ociweb.com> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_CSD_TP_QUEUE_H 00014 #define TAO_CSD_TP_QUEUE_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/Versioned_Namespace.h" 00025 00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 namespace TAO 00029 { 00030 namespace CSD 00031 { 00032 00033 class TP_Request; 00034 class TP_Queue_Visitor; 00035 00036 /** 00037 * @class TP_Queue 00038 * 00039 * @brief Queue of servant requests that need to be dispatched. 00040 * 00041 * This is the queue of pending servant requests that is "owned" 00042 * by a TP_Strategy object. When an ORB thread dispatches 00043 * a servant request to the strategy object, it will create the 00044 * appropriate (subclass of) TP_Request object to "wrap" 00045 * the servant request in a "queue-friendly" wrapper. The ORB thread 00046 * will then place the TP_Request object on to the queue. Note that 00047 * this scenario pertains to what are being called "remote requests". 00048 * There are other scenarios in which other types of requests can 00049 * get added to this queue. 00050 * 00051 * The strategy object will employ a set of worker threads that are 00052 * responsible for "servicing" the servant requests in the queue. 00053 * 00054 * Note: In the future, support will be added to allow the client 00055 * application inject "custom" TP_Request objects into 00056 * a TP_Strategy object, causing them to be placed in 00057 * the queue. 00058 */ 00059 class TAO_CSD_TP_Export TP_Queue 00060 { 00061 public: 00062 00063 /// Default Constructor. 00064 TP_Queue(); 00065 00066 /// Destructor. 00067 ~TP_Queue(); 00068 00069 /// Place a request at the end of the queue. 00070 void put(TP_Request* request); 00071 00072 /// Returns true if the queue is empty. Returns false otherwise. 00073 bool is_empty() const; 00074 00075 /// Visitors will visit each request in the queue, from front to back, 00076 /// and have the ability to stop visiting at any time (ie, before 00077 /// visiting every request). 00078 void accept_visitor(TP_Queue_Visitor& visitor); 00079 00080 00081 private: 00082 00083 /// The request at the front of the queue. 00084 TP_Request* head_; 00085 00086 /// The request at the end of the queue. 00087 TP_Request* tail_; 00088 }; 00089 00090 } 00091 } 00092 00093 TAO_END_VERSIONED_NAMESPACE_DECL 00094 00095 #if defined (__ACE_INLINE__) 00096 # include "tao/CSD_ThreadPool/CSD_TP_Queue.inl" 00097 #endif /* __ACE_INLINE__ */ 00098 00099 #include /**/ "ace/post.h" 00100 00101 #endif /* TAO_CSD_TP_QUEUE_H */