summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2014-01-16 10:37:21 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2014-01-16 10:37:21 +0000
commit2a5ad8793ea5590241785978ecc6d158bdd930ed (patch)
tree2873d62c102e0ac462fed6d534d0c7403725906a
parentd623a5b063fc9305c598cbcd9b8038f0f79ca049 (diff)
downloadATCD-2a5ad8793ea5590241785978ecc6d158bdd930ed.tar.gz
Thu Jan 16 10:36:20 UTC 2014 Johnny Willemsen <jwillemsen@remedy.nl>
* ace/High_Res_Timer.cpp: Fixed implementation of ACE_High_Res_Timer::global_scale_factor, only set the global_scale_factor_status_ when it is zero and we have the lock.
-rw-r--r--ACE/ChangeLog7
-rw-r--r--ACE/ace/High_Res_Timer.cpp38
-rw-r--r--ACE/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp2
3 files changed, 29 insertions, 18 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index d29c4940ae4..39f1f540168 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jan 16 10:36:20 UTC 2014 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * ace/High_Res_Timer.cpp:
+ Fixed implementation of ACE_High_Res_Timer::global_scale_factor,
+ only set the global_scale_factor_status_ when it is zero and we
+ have the lock.
+
Thu Jan 9 12:33:11 UTC 2014 Johnny Willemsen <jwillemsen@remedy.nl>
* etc/ace.doxygen:
diff --git a/ACE/ace/High_Res_Timer.cpp b/ACE/ace/High_Res_Timer.cpp
index 6295767b4a9..192d535055c 100644
--- a/ACE/ace/High_Res_Timer.cpp
+++ b/ACE/ace/High_Res_Timer.cpp
@@ -209,33 +209,39 @@ ACE_High_Res_Timer::global_scale_factor (void)
if (ACE_High_Res_Timer::global_scale_factor_status_ == 0)
{
# if defined (ACE_WIN32)
- // This a higher-precision version, specific for Windows systems
- LARGE_INTEGER freq;
- if (::QueryPerformanceFrequency (&freq))
- {
- ACE_High_Res_Timer::global_scale_factor(freq.QuadPart);
-
- ACE_High_Res_Timer::global_scale_factor_status_ = 1;
- }
- else
- {
- // High-Res timers not supported
- ACE_High_Res_Timer::global_scale_factor_status_ = -1;
- }
- return ACE_High_Res_Timer::global_scale_factor_;
+ // This a higher-precision version, specific for Windows systems
+ LARGE_INTEGER freq;
+ if (::QueryPerformanceFrequency (&freq))
+ {
+ ACE_High_Res_Timer::global_scale_factor(freq.QuadPart);
+
+ // Succeeded in setting the global scale factor
+ ACE_High_Res_Timer::global_scale_factor_status_ = 1;
+ }
+ else
+ {
+ // High-Res timers not supported
+ ACE_High_Res_Timer::global_scale_factor_status_ = -1;
+ }
# elif defined (ACE_LINUX)
- ACE_High_Res_Timer::global_scale_factor (ACE_High_Res_Timer::get_cpuinfo ());
+ ACE_High_Res_Timer::global_scale_factor (ACE_High_Res_Timer::get_cpuinfo ());
# endif /* ! ACE_WIN32 && ! (ACE_LINUX && __alpha__) */
# if !defined (ACE_WIN32)
if (ACE_High_Res_Timer::global_scale_factor_ <= 1u)
// Failed to retrieve CPU speed from system, so calculate it.
ACE_High_Res_Timer::calibrate ();
+
+ // We have set the global scale factor so set out status
+ // to 1, this way we only set the global_scale_factor_ once.
+ // Must be in the !ACE_WIN32 block to make sure that we
+ // not change a value of -1 (only done for ACE_WINC32) by accident
+ // to 1
+ ACE_High_Res_Timer::global_scale_factor_status_ = 1;
# endif // (ACE_WIN32)
}
}
- ACE_High_Res_Timer::global_scale_factor_status_ = 1;
#endif /* (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \
ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) && \
! ACE_HAS_HI_RES_TIMER &&
diff --git a/ACE/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp b/ACE/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp
index 43407bf36b6..d53e6d468e6 100644
--- a/ACE/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp
+++ b/ACE/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp
@@ -23,8 +23,6 @@
#include "ace/OS_NS_fcntl.h"
#include "ace/Log_Msg.h"
-
-
static int stop_test = 0;
static const ACE_TCHAR *directory = ACE_TEXT (".");
static const ACE_TCHAR *temp_file = ACE_TEXT ("foo");