Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Collocated_DerivedIF / Hello.cpp
blobd126eb34a3b78064f73e55d407f1610e14654f92
1 #include "Hello.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/ORB_Table.h"
4 #include "tao/ORB_Core_Auto_Ptr.h"
6 HelloAgain::HelloAgain (CORBA::ORB_ptr orb,
7 ACE_thread_t thrid)
8 : orb_ (CORBA::ORB::_duplicate (orb))
9 , thr_id_ (thrid)
12 char *
13 HelloAgain::get_string_again ()
15 ACE_DEBUG ((LM_DEBUG,
16 "(%P|%t) Upcall get_string_again in process ..\n"));
18 /// Use portable thread IDs
19 ACE_Thread_ID self_ID;
20 // Thread ID from Server
21 ACE_Thread_ID this_ID;
22 this_ID.id(this->thr_id_);
24 // Servant Thread ID same as Thread ID server, so a remote call,
25 // in case of a collocation the servant runs in calling thread (Client)
26 if (self_ID == this_ID)
28 ACE_ERROR ((LM_ERROR,"(%P|%t) ERROR: A remote call has been made \n"));
30 else
32 if (this->orb_->orb_core ()->optimize_collocation_objects () &&
33 this->orb_->orb_core ()->use_global_collocation ())
35 ACE_DEBUG ((LM_DEBUG,
36 "(%P|%t)OK: An expected collocated call has been made \n"));
39 return CORBA::string_dup ("Bye!");
42 char *
43 HelloAgain::get_string ()
45 ACE_DEBUG ((LM_DEBUG,
46 "(%P|%t) HelloAgain::get_string Upcall get_string in process ..\n"));
48 // Use portable thread IDs
49 ACE_Thread_ID self_ID;
50 // Thread ID from Server
51 ACE_Thread_ID this_ID;
52 this_ID.id(this->thr_id_);
54 // Servant Thread ID same as Thread ID server, so a remote call,
55 // in case of a collocation the servant runs in calling thread (Client)
56 if (self_ID == this_ID)
58 ACE_ERROR ((LM_ERROR,"(%P|%t) ERROR: A remote call has been made \n"));
60 else
62 if (this->orb_->orb_core ()->optimize_collocation_objects () &&
63 this->orb_->orb_core ()->use_global_collocation ())
65 ACE_DEBUG ((LM_DEBUG,
66 "(%P|%t) OK: An expected collocated call has been made \n"));
69 return CORBA::string_dup ("Hello there!");
71 void
72 HelloAgain::shutdown ()
74 // Give the client thread time to return from the collocated
75 // call to this method before shutting down the ORB. We sleep
76 // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
77 ACE_OS::sleep (1);
78 this->orb_->shutdown (false);