00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file CSD_TP_Dispatchable_Visitor.h 00006 * 00007 * $Id: CSD_TP_Dispatchable_Visitor.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_DISPATCHABLE_VISITOR_H 00014 #define TAO_CSD_TP_DISPATCHABLE_VISITOR_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_Queue_Visitor.h" 00025 #include "tao/CSD_ThreadPool/CSD_TP_Request.h" 00026 00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 namespace TAO 00030 { 00031 namespace CSD 00032 { 00033 00034 /** 00035 * @class TP_Dispatchable_Visitor 00036 * 00037 * @brief Used to extract the first "dispatchable" request from the queue. 00038 * 00039 * An instance of this visitor class is used by one of the worker 00040 * threads to locate the first "dispatchable" request in the queue. If 00041 * such a request is visited, then this visitor will save a "copy" of 00042 * the request, indicate that the request should be removed from the 00043 * queue, and indicate that visitation should stop. 00044 * 00045 * An method is provided to retrieve a "copy" of the "dispatchable" 00046 * request that was saved off during visitation. A nil reference 00047 * (ie, a NULL pointer) will be returned if no dispatchable request 00048 * was found. 00049 * 00050 */ 00051 class TAO_CSD_TP_Export TP_Dispatchable_Visitor : public TP_Queue_Visitor 00052 { 00053 public: 00054 00055 /// Default Constructor. 00056 TP_Dispatchable_Visitor(); 00057 00058 /// Virtual Destructor. 00059 virtual ~TP_Dispatchable_Visitor(); 00060 00061 /// Reset this visitor object in order to re-use it for another 00062 /// visitation of the request queue. This sets the vistor's "result" 00063 /// (the TP_Request* data member) to its default value (a nil handle). 00064 void reset(); 00065 00066 /// Returns true to continue visitation. Returns false to stop 00067 /// visitation. Sets the remove_flag to true if the request should 00068 /// be removed from the queue as a result of the visit. Leaves the 00069 /// remove_flag alone otherwise. 00070 virtual bool visit_request(TP_Request* request, bool& remove_flag); 00071 00072 /// This returns a "copy" of the located request, or 0 if no request 00073 /// was located. 00074 TP_Request* request(); 00075 00076 00077 private: 00078 00079 /// A handle to the located request. 00080 TP_Request_Handle request_; 00081 }; 00082 00083 } 00084 } 00085 00086 TAO_END_VERSIONED_NAMESPACE_DECL 00087 00088 #if defined (__ACE_INLINE__) 00089 # include "tao/CSD_ThreadPool/CSD_TP_Dispatchable_Visitor.inl" 00090 #endif /* __ACE_INLINE__ */ 00091 00092 #include /**/ "ace/post.h" 00093 00094 #endif /* TAO_CSD_TP_DISPATCHABLE_VISITOR_H */