Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Bug_3068_Regression / test_i.cpp
blobcc2ff9cf0abb2c3f43b444b45c0753e83f2b3ad5
1 #include "test_i.h"
3 #include "tao/ORB_Core.h"
4 #include "tao/debug.h"
5 #include "tao/Transport_Cache_Manager.h"
6 #include "tao/Thread_Lane_Resources.h"
7 #include "ace/OS_NS_unistd.h"
9 #if !defined(__ACE_INLINE__)
10 #include "test_i.inl"
11 #endif /* __ACE_INLINE__ */
13 void
14 Callback_i::shutdown ()
16 ACE_DEBUG ((LM_DEBUG, "Performing clean shutdown\n"));
17 this->orb_->shutdown (false);
20 void
21 Callback_i::callback_method (const CORBA::OctetSeq &)
23 static int count = 0;
24 if (count++ > 0)
25 ACE_OS::exit(0);
29 // ****************************************************************
31 CORBA::Long
32 Simple_Server_i::test_method (CORBA::Boolean do_callback)
34 if (do_callback && this->caller_ != 0)
36 this->caller_->go ();
39 return 0;
43 void
44 Simple_Server_i::ow_test ()
46 int iter = this->ow_count_++;
47 ACE_DEBUG ((LM_DEBUG, "%t: Invoking ow test, iter = %d\n", iter));
50 void
51 Simple_Server_i::callback_object (Callback_ptr callback)
53 this->caller_ = new Caller (callback, orb_.in ());
56 Caller::Caller (Callback_ptr callback, CORBA::ORB_ptr orb)
57 : cbobj_ (Callback::_duplicate (callback))
58 , orb_ (CORBA::ORB::_duplicate (orb))
59 , cond_ (this->lock_)
60 , going_ (false)
62 this->payload_.length (0); //10000);
63 this->activate (THR_JOINABLE | THR_NEW_LWP, 4);
64 ACE_OS::sleep (1);
65 ACE_DEBUG ((LM_DEBUG, "%t returning\n"));
68 void
69 Caller::go ()
71 this->lock_.acquire ();
72 this->going_ = true;
73 this->cond_.broadcast ();
74 this->lock_.release ();
77 int
78 Caller::svc ()
80 this->lock_.acquire ();
81 ACE_DEBUG ((LM_DEBUG, "%t Getting ready to call\n"));
82 while (!this->going_) this->cond_.wait ();
83 this->lock_.release ();
84 try
86 while (1)
88 ACE_DEBUG ((LM_DEBUG, "%t calling, payload len = %d\n",
89 payload_.length ()));
90 this->cbobj_->callback_method (this->payload_);
91 ACE_DEBUG ((LM_DEBUG, "%t callback returned\n"));
92 ACE_Time_Value tv (0, 100);
93 ACE_OS::sleep (tv);
96 catch (const CORBA::Exception &ex)
98 ACE_DEBUG ((LM_DEBUG, "%t caught: %C\n", ex._name ()));
102 ACE_OS::sleep (1);
103 this->orb_->shutdown (false);
105 catch (const CORBA::Exception &ex)
107 ACE_DEBUG ((LM_DEBUG, "%t orb shutdown raised %C\n", ex._name ()));
109 return 0;
112 void
113 Simple_Server_i::shutdown ()
115 this->orb_->shutdown (false);