=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tests / Collocated_NoColl / Hello.cpp
blobd516f1a29845222659180db88f52f9792b0ea4c4
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 Hello::Hello (CORBA::ORB_ptr orb,
7 ACE_thread_t thrid)
8 : orb_ (CORBA::ORB::_duplicate (orb))
9 , thr_id_ (thrid)
13 char *
14 Hello::get_string ()
16 ACE_DEBUG ((LM_DEBUG,
17 "(%P|%t) Upcall in process ..\n"));
19 // Use portable thread IDs
20 ACE_Thread_ID self_ID;
21 // Thread ID from Server
22 ACE_Thread_ID this_ID;
23 this_ID.id(this->thr_id_);
25 // Servant Thread ID same as Thread ID server, so a remote call,
26 // in case of a collocation the servant runs in calling thread (Client)
27 if (self_ID == this_ID)
29 if (this->orb_->orb_core ()->optimize_collocation_objects () &&
30 this->orb_->orb_core ()->use_global_collocation ())
32 ACE_DEBUG ((LM_DEBUG,
33 "(%P|%t) OK: A remote call has been made \n"));
35 else if (this->orb_->orb_core ()->optimize_collocation_objects () &&
36 this->orb_->orb_core ()->use_global_collocation () == 0)
38 TAO::ORB_Table * const orb_table =
39 TAO::ORB_Table::instance ();
41 TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb"));
42 if (tmp.get () == nullptr)
44 // We are running on a single ORB and this is an error.
45 ACE_ERROR ((LM_ERROR,
46 "(%P|%t) ERROR: A remote call has been made "
47 " with a single ORB "
48 " exiting ..\n"));
49 ACE_OS::abort ();
53 else
55 if (this->orb_->orb_core ()->optimize_collocation_objects () &&
56 this->orb_->orb_core ()->use_global_collocation ())
58 ACE_ERROR ((LM_ERROR,
59 "(%P|%t) ERROR: An unexpected collocated call has been made \n"));
62 return CORBA::string_dup ("Hello there!");
65 void
66 Hello::shutdown ()
68 // Give the client thread time to return from the collocated
69 // call to this method before shutting down the ORB. We sleep
70 // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
71 ACE_OS::sleep (1);
72 this->orb_->shutdown (false);