diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2014-01-16 10:37:21 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2014-01-16 10:37:21 +0000 |
commit | 2a5ad8793ea5590241785978ecc6d158bdd930ed (patch) | |
tree | 2873d62c102e0ac462fed6d534d0c7403725906a /ACE/ace/High_Res_Timer.cpp | |
parent | d623a5b063fc9305c598cbcd9b8038f0f79ca049 (diff) | |
download | ATCD-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.
Diffstat (limited to 'ACE/ace/High_Res_Timer.cpp')
-rw-r--r-- | ACE/ace/High_Res_Timer.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
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 && |