Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / Activation_Manager.h
blob65010114bbf1a1649149742212a2eb7cd630d252
1 /* -*- C++ -*- */
2 /**
3 * @file Activation_Manager.h
5 * @author Pradeep Gore <pradeep@oomworks.com>
6 */
8 #ifndef TAO_Notify_Tests_ACTIVATION_MANAGER_H
9 #define TAO_Notify_Tests_ACTIVATION_MANAGER_H
10 #include /**/ "ace/pre.h"
12 #include "notify_test_export.h"
14 #if !defined (ACE_LACKS_PRAGMA_ONCE)
15 # pragma once
16 #endif /* ACE_LACKS_PRAGMA_ONCE */
18 #include "ace/Null_Mutex.h"
19 #include "ace/SString.h"
20 #include "ace/Hash_Map_Manager.h"
21 #include "Task_Callback.h"
22 #include "Periodic_Supplier.h"
23 #include "Periodic_Consumer.h"
24 #include "Activation_ManagerS.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 class ACE_Barrier;
28 ACE_END_VERSIONED_NAMESPACE_DECL
30 /**
31 * @class TAO_Notify_Tests_Activation_Manager
33 * @brief Class to handle Suppliers and Consumers.
35 class TAO_NOTIFY_TEST_Export TAO_Notify_Tests_Activation_Manager : public TAO_Notify_Tests_Task_Callback
36 , public POA_Notify_Test::Activation_Manager
38 typedef ACE_Hash_Map_Manager<ACE_CString, TAO_Notify_Tests_Periodic_Supplier*, ACE_SYNCH_NULL_MUTEX> TAO_Notify_Tests_PeriodicSupplier_Map;
39 typedef ACE_Hash_Map_Manager<ACE_CString, TAO_Notify_Tests_Periodic_Consumer*, ACE_SYNCH_NULL_MUTEX> TAO_Notify_Tests_PeriodicConsumer_Map;
40 typedef ACE_Hash_Map_Iterator<ACE_CString, TAO_Notify_Tests_Periodic_Supplier*, ACE_SYNCH_NULL_MUTEX> TAO_Notify_Tests_PeriodicSupplier_Iterator;
41 typedef ACE_Hash_Map_Iterator<ACE_CString, TAO_Notify_Tests_Periodic_Consumer*, ACE_SYNCH_NULL_MUTEX> TAO_Notify_Tests_PeriodicConsumer_Iterator;
42 typedef ACE_Hash_Map_Entry<ACE_CString, TAO_Notify_Tests_Periodic_Supplier*> TAO_Notify_Tests_PeriodicSupplier_Entry;
43 typedef ACE_Hash_Map_Entry<ACE_CString, TAO_Notify_Tests_Periodic_Consumer*> TAO_Notify_Tests_PeriodicConsumer_Entry;
45 public:
46 /// Constructor
47 TAO_Notify_Tests_Activation_Manager ();
49 /// Destructor
50 virtual ~TAO_Notify_Tests_Activation_Manager ();
52 /// Interface impl.
53 virtual void start ();
55 /// Register Supplier
56 void _register (TAO_Notify_Tests_Periodic_Supplier* supplier, const char* obj_name);
57 /// Register Consumer
58 void _register (TAO_Notify_Tests_Periodic_Consumer* consumer, const char* obj_name);
60 /// Resolve Supplier
61 void resolve (TAO_Notify_Tests_Periodic_Supplier*& supplier, const char* obj_name);
63 /// Resolve Consumer
64 void resolve (TAO_Notify_Tests_Periodic_Consumer*& consumer, const char* obj_name);
66 // Activate the tasks for each supplier.
67 int activate_suppliers ();
69 // Supplier Count
70 int supplier_count ();
72 // Consumer Count
73 int consumer_count ();
75 /// Wait till active suppliers and consumers are done.
76 void wait_for_completion ();
78 /// TAO_Notify_Tests_Task_Callback methods
79 virtual void done (TAO_Notify_Tests_Periodic_Supplier* supplier);
80 virtual void done (TAO_Notify_Tests_Periodic_Consumer* consumer);
82 // Dump stats gathered during exec..
83 void dump_stats (int dump_samples);
85 // Returns 0 if the file could be opened for write.
86 int ior_output_file (const ACE_TCHAR *file_name);
88 // Returns 1 if the file could be opened for read.
89 int ior_input_file (const ACE_TCHAR *file_name);
91 void write_ior ();
92 void wait_for_start_signal ();
93 void signal_peer ();
95 protected:
96 /// Lock to serialize internal state.
97 TAO_SYNCH_MUTEX lock_;
99 /// The barrier to synch all supplier on so that everyone starts at the same instance.
100 ACE_Barrier* barrier_;
102 /// Number of Active suppliers (still running a ACE_Task and sending events)
103 int active_suppliers_;
105 /// Number of Active consumers (still receiving events)
106 int active_consumers_;
108 // Condition that all active suppliers and consumers are done.
109 TAO_SYNCH_CONDITION active_done_;
111 // Map that stores suppliers.
112 TAO_Notify_Tests_PeriodicSupplier_Map supplier_map_;
114 // Map that stores consumers.
115 TAO_Notify_Tests_PeriodicConsumer_Map consumer_map_;
117 /// The file for output
118 FILE *ior_output_file_;
120 /// The file for input
121 ACE_TString ior_input_file_;
123 /// Set when the start method is called.
124 CORBA::Boolean started_;
126 // Condition that the start method has been called.
127 TAO_SYNCH_CONDITION started_condition_;
130 #include /**/ "ace/post.h"
131 #endif /* TAO_Notify_Tests_ACTIVATION_MANAGER_H */