Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / examples / Notify / ThreadPool / Consumer.h
blob131c4b81deb05db13adfa94f85763d4540cc34e6
1 /* -*- C++ -*- */
2 /**
3 * @file Consumer.h
5 * @author Pradeep Gore <pradeep@oomworks.com>
6 */
8 #ifndef TAO_Notify_CONSUMER_H
9 #define TAO_Notify_CONSUMER_H
11 #include /**/ "ace/pre.h"
13 #include "ORB_Objects.h"
14 #include "tao/RTCORBA/RTCORBA.h"
15 #include "orbsvcs/CosNotifyChannelAdminS.h"
16 #include "orbsvcs/CosNotifyCommC.h"
17 #include "ace/SString.h"
18 #include "ace/OS_NS_time.h"
20 /**
21 * @class TAO_Notify_ThreadPool_Consumer
23 * @brief Consumer
26 class TAO_Notify_ThreadPool_Consumer
27 : public POA_CosNotifyComm::StructuredPushConsumer
29 public:
30 /// Constructor
31 TAO_Notify_ThreadPool_Consumer (TAO_Notify_ORB_Objects& orb_objects);
33 /// Init
34 void init (PortableServer::POA_var& poa, CosNotifyChannelAdmin::ConsumerAdmin_var& admin, int proxy_supplier_thread_count, int max_events, long delay);
36 /// Run
37 void run (void);
39 /// Print the consumer throughput
40 void dump_throughput (void);
42 protected:
43 // = Methods
44 /// Destructor
45 virtual ~TAO_Notify_ThreadPool_Consumer (void);
47 /// Connect the Consumer to the EventChannel.
48 /// Creates a new proxy supplier and connects to it.
49 void connect (void);
51 /// Disconnect the supplier.
52 void disconnect (void);
54 /// Deactivate.
55 void deactivate (void);
57 // = ServantBase operations
58 virtual PortableServer::POA_ptr _default_POA (void);
60 // = NotifyPublish method
61 virtual void offer_change (
62 const CosNotification::EventTypeSeq & added,
63 const CosNotification::EventTypeSeq & removed);
65 // = StructuredPushSupplier methods
66 virtual void push_structured_event (
67 const CosNotification::StructuredEvent & notification);
69 virtual void disconnect_structured_push_consumer ();
71 // = Data members
73 /// Lock
74 TAO_SYNCH_MUTEX lock_;
76 /// ORB Objects.
77 TAO_Notify_ORB_Objects orb_objects_;
79 // POA.
80 PortableServer::POA_var default_POA_;
82 /// The proxy that we are connected to.
83 CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier_;
85 /// The proxy_supplier id.
86 CosNotifyChannelAdmin::ProxyID proxy_supplier_id_;
88 // The Consumer Admin
89 CosNotifyChannelAdmin::ConsumerAdmin_var admin_;
91 /// The Type the Consumer should subscribe to.
92 ACE_CString event_type_;
94 /// ProxySupplier thread count.
95 int proxy_supplier_thread_count_;
97 /// Max events to receive
98 int max_events_;
100 /// Count the number of events received.
101 int events_received_count_;
103 /// Time when the first sample was received.
104 //ACE_UINT64 t_first_;
105 ACE_hrtime_t t_first_;
107 /// Time when the last sample was received.
108 //ACE_UINT64 t_last_;
109 ACE_hrtime_t t_last_;
111 /// Delay: Sec of wait in each push.
112 ACE_Time_Value delay_;
115 #include /**/ "ace/post.h"
116 #endif /* TAO_Notify_CONSUMER_H */