From cc4ee4627feb1a27dc69e638dd6df3b850c6b334 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 14 Mar 2014 15:57:00 +0000 Subject: Fri Mar 14 15:58:19 UTC 2014 Johnny Willemsen * tests/Auto_Event_Test.cpp: Use atomic op for amount of timeouts to fix data race reported by Intel Inspector XE --- ACE/tests/Auto_Event_Test.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ACE/tests/Auto_Event_Test.cpp') 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 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"))); -- cgit v1.2.1