Merge pull request #2316 from jwillemsen/jwi-taskcommenttypo
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / performance-tests / Throughput / Throughput.h
blobc59c08aca1107dcc9f2e85d534fb3469c2384490
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file Throughput.h
6 * @author Pradeep Gore <pradeep@cs.wustl.edu>
7 */
8 //=============================================================================
11 #ifndef NOTIFY_Throughput_H
12 #define NOTIFY_Throughput_H
14 #include "Notify_Test_Client.h"
15 #include "Notify_StructuredPushConsumer.h"
16 #include "Notify_StructuredPushSupplier.h"
17 #include "ace/Task.h"
18 #include "ace/Stats.h"
19 #include "ace/Throughput_Stats.h"
20 #include "ace/High_Res_Timer.h"
21 #include "ace/Sched_Params.h"
23 #if defined(_MSC_VER)
24 #pragma warning(push)
25 #pragma warning(disable:4250)
26 #endif /* _MSC_VER */
28 /**
29 * @class Worker
31 * @brief Run a server thread
33 * Use the ACE_Task_Base class to run server threads
35 class Worker : public ACE_Task_Base
37 public:
38 /// ctor
39 Worker ();
41 void orb (CORBA::ORB_ptr orb);
43 /// The thread entry point.
44 virtual int svc ();
46 int done_;
48 private:
49 /// The orb
50 CORBA::ORB_var orb_;
53 /***************************************************************************/
55 class Notify_Throughput;
57 class Throughput_StructuredPushConsumer
58 : public TAO_Notify_Tests_StructuredPushConsumer
60 public:
61 /// Constructor.
62 Throughput_StructuredPushConsumer (Notify_Throughput *test_client);
64 // = StructuredPushSupplier methods
65 virtual void push_structured_event (
66 const CosNotification::StructuredEvent & notification);
68 /// Accumulate the throughput statistics into <throughput>
69 void accumulate_into (ACE_Throughput_Stats &throughput) const;
71 /// Accumulate the throughput statistics into <throughput>
72 void dump_stats (const ACE_TCHAR* msg,
73 ACE_High_Res_Timer::global_scale_factor_type gsf);
75 protected:
76 Notify_Throughput * test_client_;
78 /// Protect internal state
79 TAO_SYNCH_MUTEX lock_;
81 /// The timestamp for the first message received
82 ACE_hrtime_t throughput_start_;
84 /// Used for reporting stats
85 ACE_Throughput_Stats throughput_;
87 /// The number of push() calls
88 int push_count_;
91 /***************************************************************************/
93 class Throughput_StructuredPushSupplier
94 : public TAO_Notify_Tests_StructuredPushSupplier,
95 public ACE_Task_Base
97 public:
98 /// Constructor.
99 Throughput_StructuredPushSupplier (Notify_Throughput * test_client);
101 /// Destructor.
102 virtual ~Throughput_StructuredPushSupplier ();
104 // = The ACE_Task_Base methods....
105 virtual int svc ();
107 /// Accumulate the throughput statistics into <throughput>
108 void accumulate_into (ACE_Throughput_Stats &throughput) const;
110 /// Accumulate the throughput statistics into <throughput>
111 void dump_stats (const ACE_TCHAR* msg,
112 ACE_High_Res_Timer::global_scale_factor_type gsf);
114 protected:
115 Notify_Throughput* test_client_;
117 /// Count the number of push() calls
118 int push_count_;
120 /// The time for the first event sent
121 ACE_hrtime_t throughput_start_;
123 /// Measure the elapsed time spent while sending the events.
124 ACE_Throughput_Stats throughput_;
127 /***************************************************************************/
129 class Notify_Throughput : public Notify_Test_Client
131 public:
132 // Initialization and termination code
133 Notify_Throughput ();
134 virtual ~Notify_Throughput ();
136 int parse_args(int argc, ACE_TCHAR *argv[]) ;
138 /// initialization.
139 int init (int argc, ACE_TCHAR *argv []);
141 /// Run the test.
142 void run_test ();
144 /// Peers call this when done.
145 void peer_done ();
147 /// check if we got the expected results.
148 void dump_results ();
150 Worker worker_;
151 protected:
152 /// Create participants.
153 void create_EC ();
155 /// is the ec collocated.
156 CORBA::Boolean collocated_ec_;
158 /// How many bursts we will send from each supplier.
159 int burst_count_;
161 /// The time between each event burst, in microseconds.
162 int burst_pause_;
164 /// Number of events to send per supplier in every burst
165 int burst_size_;
167 /// data size to transmit.
168 int payload_size_;
170 /// the payload.
171 char *payload_;
173 /// Consumer count
174 int consumer_count_;
176 /// Supplier count
177 int supplier_count_;
179 /// Number of events received that each consumer expects to see.
180 int perconsumer_count_;
182 /// The name of the EC to resolve.
183 ACE_CString ec_name_;
185 /// The one channel that we create using the factory.
186 CosNotifyChannelAdmin::EventChannel_var ec_;
188 /// The consumer admin used by consumers.
189 CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin_;
191 /// The supplier admin used by suppliers.
192 CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin_;
194 /// Consumers
195 Throughput_StructuredPushConsumer** consumers_;
197 /// Suppliers
198 Throughput_StructuredPushSupplier** suppliers_;
200 int nthreads_;
202 // = Helpers to signal done.
203 /// how many peers are done.
204 int peer_done_count_;
206 /// The lock to serialize access to members.
207 TAO_SYNCH_MUTEX lock_;
209 /// exit wait condition
210 TAO_SYNCH_CONDITION condition_;
211 private:
212 friend class Throughput_StructuredPushSupplier;
213 friend class Throughput_StructuredPushConsumer;
216 /***************************************************************************/
218 #if defined(_MSC_VER)
219 #pragma warning(pop)
220 #endif /* _MSC_VER */
222 #endif /* NOTIFY_TESTS_EventS_H */