summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-07-01 19:46:20 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-07-01 19:46:20 +0000
commit7c2b5d9f2f265eb0e0256c2f788dd2b367160985 (patch)
tree444e0e17a2c228800e8b5d02049e1907441bbcb8 /ace
parent3051c8de862cd0f18f4d97cc95bd58930144a18c (diff)
downloadATCD-7c2b5d9f2f265eb0e0256c2f788dd2b367160985.tar.gz
(gettime): use gettime () static function to wrap all calls to ACE_OS::gethrtime (). On ACE_WIN32, if the global scale factor has not been set, then use ACE_OS::gettimeofday () instead of ACE_OS::gethrtime (), because gettimeofday doesn't need the scale factor
Diffstat (limited to 'ace')
-rw-r--r--ace/High_Res_Timer.h31
-rw-r--r--ace/High_Res_Timer.i82
2 files changed, 73 insertions, 40 deletions
diff --git a/ace/High_Res_Timer.h b/ace/High_Res_Timer.h
index d119b529075..b7125335c90 100644
--- a/ace/High_Res_Timer.h
+++ b/ace/High_Res_Timer.h
@@ -70,17 +70,6 @@ public:
// environment variable. Returns 0 on success, -1 on failure. Note
// if <env> points to string "0" (value zero), this call will fail.
- static ACE_Time_Value gettimeofday (void);
- // Calls ACE_High_Res_Timer::hrtime_to_tv passing ACE_OS::gethrtime.
- // This function can be used to parameterize objects such as
- // ACE_Timer_Queue::gettimeofday. If global_scale_factor_ is not
- // set, and we're on a platform that requires global_scale_factor_
- // (e.g., Win32), ACE_OS::gettimeofday will be used instead of
- // ACE_OS::gethrtime. This allows applications on Intel to use
- // High_Res_Timer even when global_scale_factor is not set.
- // However, setting the global_scale_factor_ appropriately will
- // result in the finest resolution possible.
-
ACE_High_Res_Timer (void);
// Initialize the timer.
@@ -134,11 +123,31 @@ public:
ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
+ static ACE_Time_Value gettimeofday (void);
+ // THIS FUNCTION IS DEPRECATED. PLEASE USE ACE_OS::gettimeofday ()
+ // INSTEAD!
+ // Calls ACE_High_Res_Timer::hrtime_to_tv passing ACE_OS::gethrtime.
+ // This function can be used to parameterize objects such as
+ // ACE_Timer_Queue::gettimeofday. If global_scale_factor_ is not
+ // set, and we're on a platform that requires global_scale_factor_
+ // (e.g., Win32), ACE_OS::gettimeofday will be used instead of
+ // ACE_OS::gethrtime. This allows applications on Intel to use
+ // High_Res_Timer even when global_scale_factor is not set.
+ // However, setting the global_scale_factor_ appropriately will
+ // result in the finest resolution possible.
+
private:
static void hrtime_to_tv (ACE_Time_Value &tv,
ACE_hrtime_t hrt);
// Converts an <hrt> to <tv> using global_scale_factor_.
+ static ACE_hrtime_t gettime ();
+ // For internal use: gets the high-resolution time using
+ // ACE_OS::gethrtime (). Except on platforms that require
+ // that the global_scale_factor_ be set, such as ACE_WIN32,
+ // uses the low-resolution clock if the global_scale_factor_
+ // has not been set.
+
ACE_hrtime_t start_;
// Starting time.
diff --git a/ace/High_Res_Timer.i b/ace/High_Res_Timer.i
index 59f305d2e09..580ceab7d04 100644
--- a/ace/High_Res_Timer.i
+++ b/ace/High_Res_Timer.i
@@ -3,6 +3,55 @@
// High_Res_Timer.i
+ACE_INLINE void
+ACE_High_Res_Timer::hrtime_to_tv (ACE_Time_Value &tv,
+ ACE_hrtime_t hrt)
+{
+ // The following are based on the units of global_scale_factor_
+ // being 1/microsecond. Therefore, dividing by it converts
+ // clock ticks to microseconds.
+ tv.sec ((long) (hrt / global_scale_factor_) / 1000000);
+ tv.usec ((long) (hrt / global_scale_factor_) % 1000000);
+}
+
+
+ACE_INLINE ACE_Time_Value
+ACE_High_Res_Timer::gettimeofday (void)
+{
+#if defined (ACE_WIN32)
+ // If the global_scale_factor_ == 1 and we're on an Intel platform,
+ // then a scale factor is needed by the platform gethrtime. Since
+ // one has not been set, just return ACE_OS::gettimeofday.
+ if (ACE_High_Res_Timer::global_scale_factor_ == 1)
+ return ACE_OS::gettimeofday ();
+#endif /* ACE_WIN32 */
+
+ ACE_Time_Value tv;
+ ACE_High_Res_Timer::hrtime_to_tv (tv,
+ ACE_OS::gethrtime ());
+ return tv;
+}
+
+
+ACE_INLINE ACE_hrtime_t
+ACE_High_Res_Timer::gettime (void)
+{
+#if defined (ACE_WIN32)
+ // If the global_scale_factor_ == 1 and we're on an Intel platform,
+ // then a scale factor is needed by the platform gethrtime. Since
+ // one has not been set, just return ACE_OS::gettimeofday.
+ if (ACE_High_Res_Timer::global_scale_factor_ == 1)
+ {
+ ACE_Time_Value tv = ACE_OS::gettimeofday ();
+ // Return the time in microseconds because the global_scale_factor_
+ // is 1.
+ return tv.sec () * 1000000 + tv.usec ();
+ }
+#endif /* ACE_WIN32 */
+
+ return ACE_OS::gethrtime ();
+}
+
ACE_INLINE
ACE_High_Res_Timer::ACE_High_Res_Timer (void)
{
@@ -15,28 +64,28 @@ ACE_INLINE void
ACE_High_Res_Timer::start (void)
{
ACE_TRACE ("ACE_High_Res_Timer::start");
- this->start_ = ACE_OS::gethrtime ();
+ this->start_ = ACE_High_Res_Timer::gettime ();
}
ACE_INLINE void
ACE_High_Res_Timer::stop (void)
{
ACE_TRACE ("ACE_High_Res_Timer::stop");
- this->end_ = ACE_OS::gethrtime ();
+ this->end_ = ACE_High_Res_Timer::gettime ();
}
ACE_INLINE void
ACE_High_Res_Timer::start_incr (void)
{
ACE_TRACE ("ACE_High_Res_Timer::start_incr");
- this->start_incr_ = ACE_OS::gethrtime ();
+ this->start_incr_ = ACE_High_Res_Timer::gettime ();
}
ACE_INLINE void
ACE_High_Res_Timer::stop_incr (void)
{
ACE_TRACE ("ACE_High_Res_Timer::stop_incr");
- this->total_ += ACE_OS::gethrtime () - this->start_incr_;
+ this->total_ += ACE_High_Res_Timer::gettime () - this->start_incr_;
}
ACE_INLINE void
@@ -50,28 +99,3 @@ ACE_High_Res_Timer::global_scale_factor (u_long gsf)
{
global_scale_factor_ = gsf;
}
-
-ACE_INLINE void
-ACE_High_Res_Timer::hrtime_to_tv (ACE_Time_Value &tv,
- ACE_hrtime_t hrt)
-{
- tv.sec ((long) (hrt / global_scale_factor_) / 1000000);
- tv.usec ((long) (hrt / global_scale_factor_) % 1000000);
-}
-
-ACE_INLINE ACE_Time_Value
-ACE_High_Res_Timer::gettimeofday (void)
-{
-#if defined (ACE_WIN32)
- // If the global_scale_factor_ == 1 and we're on an Intel platform,
- // then a scale factor is needed by the platform gethrtime. Since
- // one has not been set, just return ACE_OS::gettimeofday.
- if (ACE_High_Res_Timer::global_scale_factor_ == 1)
- return ACE_OS::gettimeofday ();
-#endif /* ACE_WIN32 */
-
- ACE_Time_Value tv;
- ACE_High_Res_Timer::hrtime_to_tv (tv,
- ACE_OS::gethrtime ());
- return tv;
-}