Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / CosEvent / Basic / Push_Event.cpp
bloba366e6783c54106ffd38f1f761ed8985644f845a
1 #include "Counting_Consumer.h"
2 #include "Counting_Supplier.h"
3 #include "orbsvcs/CosEvent/CEC_EventChannel.h"
4 #include "orbsvcs/CosEvent/CEC_Default_Factory.h"
5 #include "ace/OS_NS_unistd.h"
7 int
8 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
10 TAO_CEC_Default_Factory::init_svcs ();
12 try
14 // ORB initialization boiler plate...
15 CORBA::ORB_var orb =
16 CORBA::ORB_init (argc, argv);
18 CORBA::Object_var object =
19 orb->resolve_initial_references ("RootPOA");
20 PortableServer::POA_var poa =
21 PortableServer::POA::_narrow (object.in ());
22 PortableServer::POAManager_var poa_manager =
23 poa->the_POAManager ();
24 poa_manager->activate ();
26 // ****************************************************************
28 TAO_CEC_EventChannel_Attributes attributes (poa.in (),
29 poa.in ());
31 TAO_CEC_EventChannel ec_impl (attributes);
32 ec_impl.activate ();
34 CosEventChannelAdmin::EventChannel_var event_channel =
35 ec_impl._this ();
37 // ****************************************************************
39 // Obtain the consumer admin..
40 CosEventChannelAdmin::ConsumerAdmin_var consumer_admin =
41 event_channel->for_consumers ();
43 // Obtain the supplier admin..
44 CosEventChannelAdmin::SupplierAdmin_var supplier_admin =
45 event_channel->for_suppliers ();
47 // ****************************************************************
49 const int milliseconds = 50;
51 CEC_Counting_Supplier supplier_00;
53 supplier_00.connect (supplier_admin.in ());
55 // ****************************************************************
57 CEC_Counting_Supplier supplier_01;
59 supplier_01.connect (supplier_admin.in ());
61 // ****************************************************************
63 CEC_Counting_Supplier supplier_10;
65 supplier_10.connect (supplier_admin.in ());
67 // ****************************************************************
69 CEC_Counting_Supplier supplier_11;
71 supplier_11.connect (supplier_admin.in ());
73 // ****************************************************************
75 // Create a consumer, intialize its RT_Info structures, and
76 // connnect to the event channel....
77 CEC_Counting_Consumer consumer_00 ("Consumer/00");
78 consumer_00.connect (consumer_admin.in ());
80 // ****************************************************************
82 CEC_Counting_Consumer consumer_01 ("Consumer/01");
83 consumer_01.connect (consumer_admin.in ());
85 // ****************************************************************
87 CEC_Counting_Supplier_Task task_00 (&supplier_00, milliseconds);
88 CEC_Counting_Supplier_Task task_01 (&supplier_01, milliseconds);
89 CEC_Counting_Supplier_Task task_10 (&supplier_10, milliseconds);
90 CEC_Counting_Supplier_Task task_11 (&supplier_11, milliseconds);
92 if (task_00.activate (THR_BOUND|THR_NEW_LWP, 1) != 0)
94 ACE_ERROR ((LM_ERROR, "Cannot activate task 00\n"));
96 if (task_01.activate (THR_BOUND|THR_NEW_LWP, 1) != 0)
98 ACE_ERROR ((LM_ERROR, "Cannot activate task 01\n"));
100 if (task_10.activate (THR_BOUND|THR_NEW_LWP, 1) != 0)
102 ACE_ERROR ((LM_ERROR, "Cannot activate task 10\n"));
104 if (task_11.activate (THR_BOUND|THR_NEW_LWP, 1) != 0)
106 ACE_ERROR ((LM_ERROR, "Cannot activate task 11\n"));
109 ACE_Time_Value tv (5, 0);
110 ACE_OS::sleep (tv);
112 task_00.stop ();
113 task_01.stop ();
114 task_10.stop ();
115 task_11.stop ();
117 // Wait for all the threads to complete and the return
118 ACE_Thread_Manager::instance ()->wait ();
120 // ****************************************************************
122 consumer_01.disconnect ();
124 consumer_00.disconnect ();
126 supplier_11.disconnect ();
127 supplier_10.disconnect ();
128 supplier_01.disconnect ();
129 supplier_00.disconnect ();
131 // ****************************************************************
133 event_channel->destroy ();
135 // ****************************************************************
137 poa->destroy (true, true);
139 orb->destroy ();
141 // ****************************************************************
143 CORBA::ULong expected =
144 task_00.push_count ()
145 + task_01.push_count ()
146 + task_10.push_count ()
147 + task_11.push_count ();
149 consumer_00.dump_results (expected, 5);
150 consumer_01.dump_results (expected, 5);
152 catch (const CORBA::Exception& ex)
154 ex._tao_print_exception ("Service");
155 return 1;
157 return 0;