Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Oneway_Send_Timeouts / Test_i.cpp
bloba8cccb33fb923129fc281c35e4b858dfa66c9384
1 #include "Test_i.h"
3 #include "ace/High_Res_Timer.h"
4 #include "ace/OS_NS_unistd.h"
6 Test_i::Test_i (CORBA::ORB_ptr orb)
7 : sleep_ (false), unsleep_ (true), shutdown_ (false)
8 , orb_ (CORBA::ORB::_duplicate (orb))
9 { }
11 Test_i::~Test_i ()
13 if (!shutdown_) {
14 this->shutdown ();
16 ACE_DEBUG ((LM_DEBUG, "(%P|%t) ~Test_i>\n"));
19 void
20 Test_i::sleep (CORBA::Long sec, CORBA::Long msec)
22 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::sleep> enter\n"));
23 sleep_ = true;
24 unsleep_ = false;
26 ACE_Time_Value duration (sec);
27 duration.msec (static_cast<long> (msec)); // HPUX seems to require this cast
29 if (sec == 0 && msec == 0) {
30 // 1000 seconds is infinity
31 duration.sec (1000);
34 ACE_Time_Value current = ACE_High_Res_Timer::gettimeofday_hr ();
35 ACE_Time_Value timeout = current + duration;
37 ACE_Time_Value sleep_time;
38 sleep_time.msec (10);
39 while (current < timeout) {
40 if (!sleep_) {
41 break;
43 ACE_OS::sleep (sleep_time);
44 current += sleep_time;
46 sleep_ = false;
47 unsleep_ = true;
48 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::sleep> exit\n"));
51 void
52 Test_i::unsleep ()
54 sleep_ = false;
56 ACE_Time_Value sleep_time;
57 sleep_time.msec (10);
58 while (unsleep_ == false) {
59 ACE_OS::sleep (sleep_time);
61 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::unsleep>\n"));
64 void
65 Test_i::dummy_one_way (const char* msg)
67 if (msg != 0) {
68 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::dummy_one_way> %.25C\n", msg));
70 // do nothing
73 void
74 Test_i::dummy_two_way ()
76 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::dummy_two_way>\n"));
79 void
80 Test_i::shutdown ()
82 orb_->shutdown (0);
83 shutdown_ = true;
84 ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::shutdown>\n"));