Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / Bug_1476_Regression / Client_Task.cpp
blob7a50dd9f165b172c9add842bba6571abe1530be3
2 #include "Client_Task.h"
3 #include "tao/Messaging/Messaging.h"
4 #include "tao/AnyTypeCode/Any.h"
5 #include "ace/OS_NS_unistd.h"
7 Client_Task::Client_Task (CORBA::ORB_ptr orb,
8 Test::Sender_ptr reply_gen,
9 ACE_Thread_Manager *thr_mgr,
10 int number_of_oneways)
11 : ACE_Task_Base (thr_mgr)
12 , sender_(Test::Sender::_duplicate (reply_gen))
13 , orb_ (CORBA::ORB::_duplicate (orb))
14 , number_ (number_of_oneways)
18 int
19 Client_Task::svc ()
21 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Starting client task\n"));
23 try
25 // Apply sync_none policy
26 CORBA::Object_var object =
27 orb_->resolve_initial_references ("PolicyCurrent");
29 CORBA::PolicyCurrent_var policy_current =
30 CORBA::PolicyCurrent::_narrow (object.in ());
32 if (CORBA::is_nil (policy_current.in ()))
34 ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n"));
35 return 1;
37 CORBA::Any scope_as_any;
38 scope_as_any <<= Messaging::SYNC_NONE;
40 CORBA::PolicyList policies (1); policies.length (1);
41 policies[0] =
42 orb_->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
43 scope_as_any);
44 policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
46 policies[0]->destroy ();
48 for (int i = 0; i != number_; ++i)
50 ACE_DEBUG ((LM_DEBUG,
51 "TAO (%P|%t) sending oneway invocation %d...\n", i));
53 this->sender_->send_ready_message ();
55 // Do it slowly.
56 ACE_OS::sleep(ACE_Time_Value(0,250000));
59 catch (const CORBA::Exception& ex)
61 ex._tao_print_exception ("Caught Exception");
62 return -1;
64 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client task finished\n"));
65 return 0;