Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / EC_Throughput / ECT_Consumer.h
blob61afa5046832f99d3646ba50a34a38f72294fd32
1 /* -*- C++ -*- */
2 //
3 // ============================================================================
4 //
5 // = DESCRIPTION
6 // This test to measure how many events per minute can the EC
7 // process, it also serves as an example how how to encode complex
8 // data types in a octet sequence.
9 //
10 // ============================================================================
12 #ifndef ECT_CONSUMER_H
13 #define ECT_CONSUMER_H
15 #include "ECT_Driver.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "orbsvcs/Channel_Clients_T.h"
22 #include "orbsvcs/RtecSchedulerC.h"
23 #include "orbsvcs/RtecEventChannelAdminC.h"
24 #include "ace/Task.h"
25 #include "ace/OS_NS_time.h"
26 #include "ace/Throughput_Stats.h"
28 class Test_Consumer : public POA_RtecEventComm::PushConsumer
30 // = TITLE
31 // Receive the events.
33 // = DESCRIPTION
34 // This class is a consumer of events. It subscribes for a
35 // continous ranges of event types, this permits studying the
36 // effect of the number of subscriptions for each particular kind
37 // of event on the EC.
39 public:
40 Test_Consumer (ECT_Driver* driver,
41 void* cookie,
42 int n_suppliers,
43 int stall_length = 0);
45 void connect (RtecScheduler::Scheduler_ptr scheduler,
46 const char* name,
47 int type_start,
48 int type_count,
49 RtecEventChannelAdmin::EventChannel_ptr ec);
50 // This method connects the consumer to the EC.
52 void disconnect (void);
53 // Disconnect from the EC.
55 void dump_results (const ACE_TCHAR* name,
56 ACE_Basic_Stats::scale_factor_type global_scale_factor);
57 // Print out the results
59 void accumulate (ACE_Throughput_Stats& stats) const;
60 // Add our throughput and latency statistics to <stats>
62 virtual void push (const RtecEventComm::EventSet& events);
63 virtual void disconnect_push_consumer (void);
64 // The skeleton methods.
66 private:
67 ECT_Driver* driver_;
68 // The main driver for the test.
70 void* cookie_;
71 // A magic cookie passed by the driver that we pass back in our
72 // callbacks.
74 int n_suppliers_;
75 // The number of suppliers that are feeding this consumer, we
76 // terminate once we receive a shutdown event from each supplier.
78 RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_;
79 // We talk to the EC using this proxy.
81 TAO_SYNCH_MUTEX lock_;
82 int recv_count_;
83 ACE_hrtime_t first_event_;
84 // How many events we have received.
86 ACE_Throughput_Stats throughput_;
87 // Used for reporting stats.
89 int shutdown_count_;
90 // How many shutdown events we have received.
92 int stall_length_;
93 // How long (in seconds) we wait to continue processing
94 // after receiving the first push.
97 #endif /* ECT_CONSUMER_H */