summaryrefslogtreecommitdiff
path: root/ACE/tests/Auto_Event_Test.cpp
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2014-03-14 15:57:00 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2014-03-14 15:57:00 +0000
commitcc4ee4627feb1a27dc69e638dd6df3b850c6b334 (patch)
treeb087097ba871c6b72e17068f63e8e936419862da /ACE/tests/Auto_Event_Test.cpp
parent37090a49812131254b1a3e448078883142e6e2ed (diff)
downloadATCD-cc4ee4627feb1a27dc69e638dd6df3b850c6b334.tar.gz
Fri Mar 14 15:58:19 UTC 2014 Johnny Willemsen <jwillemsen@remedy.nl>
* tests/Auto_Event_Test.cpp: Use atomic op for amount of timeouts to fix data race reported by Intel Inspector XE
Diffstat (limited to 'ACE/tests/Auto_Event_Test.cpp')
-rw-r--r--ACE/tests/Auto_Event_Test.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/ACE/tests/Auto_Event_Test.cpp b/ACE/tests/Auto_Event_Test.cpp
index beeae1d7b4c..2d20a23a190 100644
--- a/ACE/tests/Auto_Event_Test.cpp
+++ b/ACE/tests/Auto_Event_Test.cpp
@@ -22,8 +22,7 @@
#include "ace/OS_NS_sys_time.h"
#include "ace/OS_NS_time.h"
#include "ace/OS_NS_unistd.h"
-
-
+#include "ace/Atomic_Op.h"
// msec that times are allowed to differ before test fails.
#if defined (ACE_HAS_HI_RES_TIMER) || defined (ACE_HAS_AIX_HI_RES_TIMER) || \
@@ -50,7 +49,7 @@ static int n_iterations = 10;
static size_t n_workers = 10;
// Number of timeouts.
-static size_t timeouts = 0;
+static ACE_Atomic_Op<ACE_SYNCH_MUTEX, size_t> timeouts = 0;
// Number of times to call test_timeout ().
static size_t test_timeout_count = 3;
@@ -224,11 +223,11 @@ int run_main (int argc, ACE_TCHAR *argv[])
ACE_Thread_Manager::instance ()->wait ();
- size_t percent = (timeouts * 100) / (n_workers * n_iterations);
+ size_t percent = (timeouts.value () * 100) / (n_workers * n_iterations);
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Worker threads timed out %d percent of the time\n"),
- (int)percent));
+ ACE_TEXT ("Worker threads timed out %B percent of the time\n"),
+ percent));
if (test_result == 0)
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Auto_Event Test successful\n")));