Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / performance-tests / Latency / Collocation / Server_Task.cpp
blob2f40fe495b7309d0adcc1e31f1b0a1d758b71dfd
2 #include "Server_Task.h"
3 #include "Roundtrip.h"
5 Server_Task::Server_Task (CORBA::ORB_ptr sorb,
6 ACE_Manual_Event &cond,
7 ACE_Thread_Manager *thr_mgr)
8 : ACE_Task_Base (thr_mgr),
9 cond_ (cond),
10 sorb_ (CORBA::ORB::_duplicate (sorb))
14 Test::Roundtrip *
15 Server_Task::get_reference ()
17 return Test::Roundtrip::_duplicate (this->rt_var_.in ());
20 int
21 Server_Task::svc ()
23 try
25 CORBA::Object_var poa_object =
26 this->sorb_->resolve_initial_references("RootPOA");
28 PortableServer::POA_var root_poa =
29 PortableServer::POA::_narrow (poa_object.in ());
31 if (CORBA::is_nil (root_poa.in ()))
32 ACE_ERROR_RETURN ((LM_ERROR,
33 " (%P|%t) Panic: nil RootPOA\n"),
34 1);
36 PortableServer::POAManager_var poa_manager =
37 root_poa->the_POAManager ();
39 Roundtrip *rt_impl;
41 ACE_NEW_RETURN (rt_impl,
42 Roundtrip (this->sorb_.in ()),
43 1);
45 PortableServer::ServantBase_var owner_transfer(rt_impl);
47 this->rt_var_ =
48 rt_impl->_this ();
50 if (CORBA::is_nil (this->rt_var_.in ()))
52 ACE_ERROR_RETURN ((LM_DEBUG,
53 "Error activating Test::Roundtrip reference\n"),
54 1);
57 poa_manager->activate ();
59 ACE_DEBUG ((LM_DEBUG, "Server_Task: Object Activation complete\n"));
61 // Signal the main thread to spawn the client
62 this->cond_.signal ();
64 this->sorb_->run ();
66 root_poa->destroy (true, true);
68 this->sorb_->destroy ();
70 catch (const CORBA::Exception& ex)
72 ex._tao_print_exception ("Exception caught:");
73 return 1;
77 return 0;