Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / orbsvcs / tests / EC_Throughput / ECT_Consumer_Driver.h
blob32b92e1cc6da8e13001339ba0741ac6a53cf6583
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_DRIVER_H
13 #define ECT_CONSUMER_DRIVER_H
15 #include "ECT_Driver.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ECT_Consumer.h"
22 #include "orbsvcs/Channel_Clients_T.h"
23 #include "orbsvcs/RtecEventChannelAdminC.h"
24 #include "ace/Task.h"
25 #include "ace/High_Res_Timer.h"
27 class ECT_Consumer_Driver : public ECT_Driver
30 // = TITLE
32 // = DESCRIPTION
34 public:
35 ECT_Consumer_Driver ();
36 virtual ~ECT_Consumer_Driver ();
38 enum {
39 MAX_CONSUMERS = 16
40 // Maximum number of consumers.
43 int run (int argc, ACE_TCHAR* argv[]);
44 // Execute the test.
46 virtual void shutdown_consumer (void* consumer_cookie);
47 // Callback method for consumers, each consumer will call this
48 // method once it receives all the shutdown events from the
49 // suppliers.
51 private:
52 int parse_args (int argc, ACE_TCHAR* argv[]);
53 // parse the command line args
55 void connect_consumers (RtecScheduler::Scheduler_ptr scheduler,
56 RtecEventChannelAdmin::EventChannel_ptr local_ec);
57 void disconnect_consumers ();
58 // Connect and disconnect the consumers.
60 void dump_results ();
61 // Print out the results
63 private:
64 Test_Consumer* consumers_[ECT_Consumer_Driver::MAX_CONSUMERS];
65 // The consumer array.
67 int n_consumers_;
68 // The number of consumers.
70 int n_suppliers_;
71 // How many suppliers are sending events, used for shutdown, each
72 // supplier sends a shutdown message after it finishes, the consumer
73 // finishes when all the suppliers do.
75 int type_start_;
76 int type_count_;
77 // We receive the events whose type is in the range
78 // [type_start,type_start+type_count)
80 int stall_length_;
81 // How long (in seconds) the consumer will wait after receiving the first event.
83 int shutdown_event_channel_;
84 // If not zero it will shutdown the event channel upon exit.
86 const ACE_TCHAR* pid_file_name_;
87 // The name of a file where the process stores its pid
89 CORBA::ORB_var orb_;
90 // A reference to the ORB, to shut it down properly.
92 TAO_SYNCH_MUTEX lock_;
93 int active_count_;
94 // How many consumers are still receiving events.
97 #endif /* ECT_CONSUMER_DRIVER_H */