summaryrefslogtreecommitdiff
path: root/ace/Time_Value.cpp
diff options
context:
space:
mode:
authordhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-01 11:15:26 +0000
committerdhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-01 11:15:26 +0000
commitb38582354ed287367fd93be229ae5e9dbf9188e7 (patch)
tree9a2cd7fff6f9e796968703bf3bb2cb7ca5c5bf82 /ace/Time_Value.cpp
parent6a0568c32aa670b9d9c216c18ae796749c816819 (diff)
downloadATCD-b38582354ed287367fd93be229ae5e9dbf9188e7.tar.gz
ChangeLogTag:Sat Nov 1 05:40:21 UTC 2003 Don Hinton <dhinton@dresystems.com>
Diffstat (limited to 'ace/Time_Value.cpp')
-rw-r--r--ace/Time_Value.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/ace/Time_Value.cpp b/ace/Time_Value.cpp
index a9153981576..603fe34ea17 100644
--- a/ace/Time_Value.cpp
+++ b/ace/Time_Value.cpp
@@ -199,3 +199,69 @@ ACE_Time_Value::normalize (void)
this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
}
}
+
+/*****************************************************************************/
+// These need to be moved to another file due unresolvable dependency
+// issues with inlining.
+
+ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time)
+ : max_wait_time_ (max_wait_time),
+ stopped_ (0)
+{
+ this->start ();
+}
+
+ACE_Countdown_Time::~ACE_Countdown_Time (void)
+{
+ this->stop ();
+}
+
+/*****************************************************************************/
+
+//ACE_INLINE
+int
+ACE_Countdown_Time::start (void)
+{
+ if (this->max_wait_time_ != 0)
+ {
+ this->start_time_ = ACE_OS::gettimeofday ();
+ this->stopped_ = 0;
+ }
+ return 0;
+}
+
+//ACE_INLINE
+int
+ACE_Countdown_Time::stopped (void) const
+{
+ return stopped_;
+}
+
+//ACE_INLINE
+int
+ACE_Countdown_Time::stop (void)
+{
+ if (this->max_wait_time_ != 0 && this->stopped_ == 0)
+ {
+ ACE_Time_Value elapsed_time =
+ ACE_OS::gettimeofday () - this->start_time_;
+
+ if (*this->max_wait_time_ > elapsed_time)
+ *this->max_wait_time_ -= elapsed_time;
+ else
+ {
+ // Used all of timeout.
+ *this->max_wait_time_ = ACE_Time_Value::zero;
+ // errno = ETIME;
+ }
+ this->stopped_ = 1;
+ }
+ return 0;
+}
+
+//ACE_INLINE
+int
+ACE_Countdown_Time::update (void)
+{
+ return this->stop () == 0 && this->start ();
+}