Continued changes from peer review
[ACE_TAO.git] / TAO / tests / COIOP / Hello.cpp
blob78d9023ccefea9e1df3007b5b49046b2a9c7e4d5
1 // -*- C++ -*-
2 #include "Hello.h"
3 #include "tao/ORB_Core.h"
4 #include "tao/ORB_Table.h"
5 #include "tao/ORB_Core_Auto_Ptr.h"
6 #include "tao/Strategies/advanced_resource.h"
8 Hello::Hello (CORBA::ORB_ptr orb,
9 ACE_thread_t thrid)
10 : orb_ (CORBA::ORB::_duplicate (orb))
11 , thr_id_ (thrid)
15 char *
16 Hello::get_string (void)
18 ACE_DEBUG ((LM_DEBUG,
19 "(%P|%t) Upcall in process ..\n"));
21 // Use portable thread IDs
22 ACE_Thread_ID self_ID;
23 ACE_Thread_ID this_ID;
24 this_ID.id(this->thr_id_);
26 if (self_ID == this_ID)
28 if (this->orb_->orb_core ()->optimize_collocation_objects () &&
29 this->orb_->orb_core ()->use_global_collocation ())
31 ACE_ERROR ((LM_ERROR,
32 "(%P|%t) ERROR: A remote call has been made "
33 " exiting ..\n"));
34 ACE_OS::abort ();
36 else if (this->orb_->orb_core ()->optimize_collocation_objects () &&
37 this->orb_->orb_core ()->use_global_collocation () == 0)
39 TAO::ORB_Table * const orb_table =
40 TAO::ORB_Table::instance ();
42 TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb"));
43 if (tmp.get () == 0)
45 // We are running on a single ORB and this is an error.
46 ACE_ERROR ((LM_ERROR,
47 "(%P|%t) ERROR: A remote call has been made "
48 " with a single ORB "
49 " exiting ..\n"));
50 ACE_OS::abort ();
55 return CORBA::string_dup ("Hello there!");
58 void
59 Hello::shutdown (void)
61 // Give the client thread time to return from the collocated
62 // call to this method before shutting down the ORB. We sleep
63 // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
64 ACE_OS::sleep (1);
65 this->orb_->shutdown (0);