Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Collocation_Tests / Hello.cpp
blob65b1c37b7053b52016fe02bcc17a3064469ff26c
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 (void)
16 ACE_DEBUG ((LM_DEBUG,
17 "(%P|%t) Upcall in process ..\n"));
19 // Use portable thread IDs
20 ACE_Thread_ID self_ID;
21 ACE_Thread_ID this_ID;
22 this_ID.id(this->thr_id_);
24 if (self_ID == this_ID)
26 if (this->orb_->orb_core ()->optimize_collocation_objects () &&
27 this->orb_->orb_core ()->use_global_collocation ())
29 ACE_ERROR ((LM_ERROR,
30 "(%P|%t) ERROR: A remote call has been made "
31 " exiting ..\n"));
32 ACE_OS::abort ();
34 else if (this->orb_->orb_core ()->optimize_collocation_objects () &&
35 this->orb_->orb_core ()->use_global_collocation () == 0)
37 TAO::ORB_Table * const orb_table =
38 TAO::ORB_Table::instance ();
40 TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb"));
41 if (tmp.get () == 0)
43 // We are running on a single ORB and this is an error.
44 ACE_ERROR ((LM_ERROR,
45 "(%P|%t) ERROR: A remote call has been made "
46 " with a single ORB "
47 " exiting ..\n"));
48 ACE_OS::abort ();
53 return CORBA::string_dup ("Hello there!");
56 void
57 Hello::shutdown (void)
59 // Give the client thread time to return from the collocated
60 // call to this method before shutting down the ORB. We sleep
61 // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
62 ACE_OS::sleep (1);
63 this->orb_->shutdown (0);