Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / tao / CSD_ThreadPool / CSD_TP_Request.h
blobc6801b7272c5cd6ffc0feea81b8c54b0e868182d
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file CSD_TP_Request.h
7 * @author Tim Bradley <bradley_t@ociweb.com>
8 */
9 //=============================================================================
11 #ifndef TAO_CSD_TP_REQUEST_H
12 #define TAO_CSD_TP_REQUEST_H
14 #include /**/ "ace/pre.h"
16 #include "tao/CSD_ThreadPool/CSD_TP_Export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/CSD_ThreadPool/CSD_TP_Servant_State.h"
23 #include "tao/PortableServer/Servant_Base.h"
24 #include "tao/Intrusive_Ref_Count_Base_T.h"
25 #include "tao/Intrusive_Ref_Count_Handle_T.h"
27 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
29 namespace TAO
31 namespace CSD
33 class TP_Request;
34 typedef TAO_Intrusive_Ref_Count_Handle<TP_Request> TP_Request_Handle;
36 class TP_Queue;
39 /**
40 * @class TP_Request
42 * @brief Base class for "queue-able" requests.
44 * This class serves as the abstract base class for all types of
45 * "servant requests" that can be inserted into a TP_Queue
46 * object.
48 class TAO_CSD_TP_Export TP_Request
49 : public TAO_Intrusive_Ref_Count_Base<TAO_SYNCH_MUTEX>
51 public:
52 /// Virtual Destructor.
53 virtual ~TP_Request();
55 /// Prepare the request to be placed into the request queue.
56 void prepare_for_queue();
58 /// Invoked to dispatch the request to the servant.
59 void dispatch();
61 /// Invoked to cancel the request.
62 void cancel();
64 /// Is the target servant ready to accept a request?
65 bool is_ready() const;
67 /// Mark the target servant as being busy.
68 void mark_as_busy();
70 /// Mark the target servant as being ready (ie, not busy).
71 void mark_as_ready();
73 /// This method returns true if this request targets the supplied
74 /// servant object.
75 bool is_target(PortableServer::Servant servant);
78 protected:
79 /// Constructor.
80 TP_Request(PortableServer::Servant servant,
81 TP_Servant_State* servant_state);
83 /// Accessor for the servant. Does not return a new (ref counted)
84 /// reference! This is used for chaining.
85 PortableServer::Servant servant();
87 /// The subclass knows if it needs to do anything in preparation
88 /// of being placed into the request queue. The default implementation
89 /// does nothing, so only subclasses that have something to do
90 /// need to provide their own implementation.
91 virtual void prepare_for_queue_i();
93 /// The subclass knows how to carry out its own way of dispatching
94 /// the request to the servant.
95 virtual void dispatch_i() = 0;
97 /// Ask the subclass to perform its duties to carry out the cancellation.
98 virtual void cancel_i() = 0;
100 private:
101 /// The TP_Queue class is our friend since it needs access to
102 /// the prev_ and next_ (private) data members.
103 friend class TP_Queue;
105 /// The previous TP_Request object (in the queue).
106 TP_Request* prev_;
108 /// The next TP_Request object (in the queue).
109 TP_Request* next_;
111 /// Reference to the servant object.
112 PortableServer::ServantBase_var servant_;
114 /// Reference to the servant "state" object (contains the busy flag).
115 TP_Servant_State::HandleType servant_state_;
120 TAO_END_VERSIONED_NAMESPACE_DECL
122 #if defined (__ACE_INLINE__)
123 # include "tao/CSD_ThreadPool/CSD_TP_Request.inl"
124 #endif /* __ACE_INLINE__ */
126 #include /**/ "ace/post.h"
128 #endif /* TAO_CSD_TP_REQUEST_H */