Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_1551_Regression / Client_Task.cpp
blob3c2f6013b86aad5e5f807367b26aa801dadae387
1 #include "Client_Task.h"
3 Client_Task::Client_Task (Test::Hello_ptr receiver,
4 CORBA::ORB_ptr orb,
5 ACE_Thread_Manager *thr_mgr)
6 : ACE_Task_Base (thr_mgr)
7 , receiver_ (Test::Hello::_duplicate (receiver))
8 , handler_ (new Reply_Handler(receiver, orb))
9 , handler_var_ (handler_->_this())
10 , orb_ (CORBA::ORB::_duplicate (orb))
14 Client_Task::~Client_Task (void)
18 int
19 Client_Task::svc (void)
21 // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Starting client task\n"));
23 try
25 CORBA::Object_var object =
26 this->orb_->resolve_initial_references ("PolicyCurrent");
28 CORBA::PolicyCurrent_var policy_current =
29 CORBA::PolicyCurrent::_narrow (object.in ());
31 TimeBase::TimeT timeout_period = 20 * 1000;
33 CORBA::Any timeout_as_any;
34 timeout_as_any <<= timeout_period;
36 CORBA::PolicyList policy_list (1);
37 policy_list.length (1);
38 policy_list[0] =
39 this->orb_->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
40 timeout_as_any);
42 policy_current->set_policy_overrides (policy_list,
43 CORBA::ADD_OVERRIDE);
45 policy_list[0]->destroy();
47 // Start 25 separate concurrent request streams
48 for (CORBA::Short i = 0; i != 25; ++i)
50 this->receiver_->sendc_short_sleep (this->handler_var_.in ());
53 ACE_Time_Value tv(10, 0);
54 orb_->run(tv);
56 catch (const CORBA::TIMEOUT&)
58 ACE_DEBUG ((LM_DEBUG,
59 "Client received an expected CORBA::TIMEOUT exception.\n"));
61 catch (const CORBA::Exception& ex)
63 ex._tao_print_exception ("(%P|%t) Client_Task - caught exception:");
64 return -1;
67 return 0;