summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2010-06-17 22:07:42 +0000
committerSteve Huston <shuston@riverace.com>2010-06-17 22:07:42 +0000
commit00b7611eafff824dbc6c89c0f750bfd4d3356649 (patch)
tree7d73b4e4278f2873000003997c9945e5ce035894
parent8e2767ee9cc89d352067b358f56e2e075275ff09 (diff)
downloadATCD-00b7611eafff824dbc6c89c0f750bfd4d3356649.tar.gz
ChangeLogTag:Thu Jun 17 21:59:34 UTC 2010 Steve Huston <shuston@riverace.com>
-rw-r--r--ACE/ChangeLog13
-rw-r--r--ACE/NEWS12
-rw-r--r--ACE/ace/Time_Value.h23
-rw-r--r--ACE/ace/Time_Value.inl25
-rw-r--r--ACE/tests/Time_Value_Test.cpp19
5 files changed, 89 insertions, 3 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 058948efb5b..261d4c80657 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,16 @@
+Thu Jun 17 21:59:34 UTC 2010 Steve Huston <shuston@riverace.com>
+
+ * ace/Time_Value.{h inl}: Added explicit set_ and get_ methods for
+ ACE_UINT64 msec values. Also marked the existing "getter"
+ msec(ACE_UINT64&) methods deprecated because they look like
+ setter methods and are confusing. Users should change to get_msec().
+ Resolves Bugzilla #3336.
+
+ * NEWS: Described the new methods and rationale.
+
+ * tests/Time_Value_Test.cpp: Added test cases for the new
+ set_msec() and get_msec() methods.
+
Thu Jun 17 19:47:58 UTC 2010 Steve Huston <shuston@riverace.com>
* ace/DLL_Manager.cpp: Add _get_dll_unload_policy() function that
diff --git a/ACE/NEWS b/ACE/NEWS
index 924dac88252..a948d19d647 100644
--- a/ACE/NEWS
+++ b/ACE/NEWS
@@ -1,6 +1,18 @@
USER VISIBLE CHANGES BETWEEN ACE-5.7.9 and ACE-5.8.0
====================================================
+. There are two new ACE_Time_Value methods for getting and setting millisecond
+ values to/from ACE_UINT64 values:
+
+ ACE_UINT64 ACE_Time_Value::get_msec () const
+ void ACE_Time_Value::set_msec (const ACE_UINT64 &ms)
+
+ The former is a replacement for the existing msec(ACE_UINT64&) methods that
+ are "getter" methods whose signatures look confusingly like "setters". See
+ Bugzilla #3336 for the history behind this change.
+
+ The latter is for consistency and clarity.
+
USER VISIBLE CHANGES BETWEEN ACE-5.7.8 and ACE-5.7.9
====================================================
diff --git a/ACE/ace/Time_Value.h b/ACE/ace/Time_Value.h
index 5943094ef75..75bb998f598 100644
--- a/ACE/ace/Time_Value.h
+++ b/ACE/ace/Time_Value.h
@@ -129,11 +129,24 @@ public:
/// Converts from ACE_Time_Value format into milliseconds format.
/**
* @return Sum of second field (in milliseconds) and microsecond field
+ * (in milliseconds).
+ *
+ * @note The semantics of this method differs from the sec() and
+ * usec() methods. There is no analogous "millisecond"
+ * component in an ACE_Time_Value.
+ */
+ ACE_UINT64 get_msec () const;
+
+ /// Converts from ACE_Time_Value format into milliseconds format.
+ /**
+ * @return Sum of second field (in milliseconds) and microsecond field
* (in milliseconds) and return them via the @param ms parameter.
*
* @note The semantics of this method differs from the sec() and
* usec() methods. There is no analogous "millisecond"
* component in an ACE_Time_Value.
+ *
+ * @deprecated Use get_msec() instead.
*/
void msec (ACE_UINT64 &ms) const;
@@ -145,6 +158,8 @@ public:
* @note The semantics of this method differs from the sec() and
* usec() methods. There is no analogous "millisecond"
* component in an ACE_Time_Value.
+ *
+ * @deprecated Use get_msec() instead.
*/
void msec (ACE_UINT64 &ms) /* const */;
@@ -154,6 +169,14 @@ public:
* usec() methods. There is no analogous "millisecond"
* component in an ACE_Time_Value.
*/
+ void set_msec (const ACE_UINT64 &ms);
+
+ /// Converts from milli-seconds format into ACE_Time_Value format.
+ /**
+ * @note The semantics of this method differs from the sec() and
+ * usec() methods. There is no analogous "millisecond"
+ * component in an ACE_Time_Value.
+ */
void msec (long);
/// Converts from milli-seconds format into ACE_Time_Value format.
diff --git a/ACE/ace/Time_Value.inl b/ACE/ace/Time_Value.inl
index 73f9285ff2d..40ab4476290 100644
--- a/ACE/ace/Time_Value.inl
+++ b/ACE/ace/Time_Value.inl
@@ -147,13 +147,21 @@ ACE_Time_Value::msec (void) const
return ACE_Utils::truncate_cast<unsigned long> (secs);
}
-ACE_INLINE void
-ACE_Time_Value::msec (ACE_UINT64 &ms) const
+ACE_INLINE ACE_UINT64
+ACE_Time_Value::get_msec () const
{
// ACE_OS_TRACE ("ACE_Time_Value::msec");
- ms = ACE_Utils::truncate_cast<ACE_UINT64> (this->tv_.tv_sec);
+ ACE_UINT64 ms = ACE_Utils::truncate_cast<ACE_UINT64> (this->tv_.tv_sec);
ms *= 1000;
ms += (this->tv_.tv_usec / 1000);
+ return ms;
+}
+
+ACE_INLINE void
+ACE_Time_Value::msec (ACE_UINT64 &ms) const
+{
+ // ACE_OS_TRACE ("ACE_Time_Value::msec");
+ ms = this->get_msec ();
}
ACE_INLINE void
@@ -164,6 +172,17 @@ ACE_Time_Value::msec (ACE_UINT64 &ms) /*const*/
tv->msec (ms);
}
+ACE_INLINE void
+ACE_Time_Value::set_msec (const ACE_UINT64 &ms)
+{
+ // ACE_OS_TRACE ("ACE_Time_Value::msec");
+ // Convert millisecond units to seconds;
+ ACE_UINT64 secs = ms / 1000;
+ this->tv_.tv_sec = static_cast<long> (secs);
+ // Convert remainder to microseconds;
+ this->tv_.tv_usec = static_cast<long>((ms - (secs * 1000)) * 1000);
+}
+
/// Converts from milli-seconds format into Time_Value format.
ACE_INLINE void
ACE_Time_Value::msec (long milliseconds)
diff --git a/ACE/tests/Time_Value_Test.cpp b/ACE/tests/Time_Value_Test.cpp
index 1f136ead1bc..3e2e75b7841 100644
--- a/ACE/tests/Time_Value_Test.cpp
+++ b/ACE/tests/Time_Value_Test.cpp
@@ -133,6 +133,12 @@ run_main (int, ACE_TCHAR *[])
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("msec test failed: %Q should be 42555\n"),
ms));
+ ms = 0;
+ ms = msec_test.get_msec ();
+ if (ms != 42555)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("get_msec test failed: %Q should be 42555\n"),
+ ms));
ACE_Time_Value const msec_test2 (42, 555000);
ms = 0;
msec_test2.msec (ms);
@@ -141,6 +147,19 @@ run_main (int, ACE_TCHAR *[])
ACE_TEXT ("msec const test failed: %Q should be 42555\n"),
ms));
+ // Test setting from ACE_UINT64
+ ms = 42555;
+ ACE_Time_Value msec_test3;
+ msec_test3.set_msec (ms);
+ if (msec_test3.sec () != 42)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("set_msec test failed: %d secs should be 42\n"),
+ msec_test3.sec ()));
+ if (msec_test3.usec () != 555000)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("set_msec test failed: %d usecs should be 555000\n"),
+ msec_test3.usec ()));
+
#ifdef ACE_HAS_CPP98_IOSTREAMS
std::ostringstream ost;
ost << ACE_Time_Value(1);