Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / AMI_Timeouts / timeout_i.cpp
blob4bcfed427294208d2f591912f33e5cf7aa0b2e53
1 //=============================================================================
2 /**
3 * @file timeout_i.cpp
5 * Implements the timeout CORBA Object and its reply handler.
7 * @author Michael Kircher <Michael.Kircher@mchp.siemens.de>
8 */
9 //=============================================================================
11 #include "timeout_i.h"
12 #include "ace/OS_NS_unistd.h"
14 Timeout_i::Timeout_i (CORBA::ORB_ptr orb)
16 orb_ = CORBA::ORB::_duplicate (orb);
19 void
20 Timeout_i::sendTimeToWait (CORBA::Long msec)
22 //ACE_DEBUG ((LM_DEBUG,
23 // "Timeout_i::sendTimeToWait: invoked with msec = %d\n\n",
24 // msec));
26 if (msec != 0)
28 // ACE_DEBUG ((LM_DEBUG,
29 // "Timeout_i::sendTimeToWait: sleeping\n\n"));
31 ACE_Time_Value tv (0, msec * 1000);
32 ACE_OS::sleep (tv);
36 void
37 Timeout_i::shutdown ()
39 orb_->shutdown ();
40 //ACE_DEBUG ((LM_DEBUG,
41 // "Timeout_i::shutdown: shut down ORB\n\n"));
44 // Reply Handler implementation
46 TimeoutHandler_i::TimeoutHandler_i ()
47 : reply_counter_ (0)
48 , reply_excep_counter_ (0)
50 timer_.reset ();
51 timer_.start ();
52 timer_.stop ();
55 void
56 TimeoutHandler_i::sendTimeToWait ()
58 ACE_DEBUG ((LM_DEBUG,
59 "reply"));
60 ++reply_counter_;
61 timer_.stop ();
64 void
65 TimeoutHandler_i::sendTimeToWait_excep (::Messaging::ExceptionHolder *excep_holder)
67 timer_.stop ();
69 try
71 excep_holder->raise_exception ();
73 catch (const CORBA::TIMEOUT& )
75 ACE_DEBUG ((LM_DEBUG,
76 "timeout"));
77 ++reply_excep_counter_;
79 catch (...)
81 ACE_DEBUG ((LM_DEBUG,
82 "Error: Unexpected exception"));
86 void
87 TimeoutHandler_i::reset_reply_counter ()
89 reply_counter_ = 0;
92 void
93 TimeoutHandler_i::reset_reply_excep_counter ()
95 reply_excep_counter_ = 0;
98 unsigned short
99 TimeoutHandler_i::reply_counter ()
101 return reply_counter_;
104 unsigned short
105 TimeoutHandler_i::reply_excep_counter ()
107 return reply_excep_counter_;
110 void
111 TimeoutHandler_i::start ()
113 timer_.reset ();
114 timer_.start ();
117 ACE_Time_Value &
118 TimeoutHandler_i::elapsed_time ()
120 timer_.elapsed_time (elapsed_time_);
121 return elapsed_time_;