stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r554767 - /incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp
Date Mon, 09 Jul 2007 21:15:40 GMT
Author: sebor
Date: Mon Jul  9 14:15:39 2007
New Revision: 554767

URL: http://svn.apache.org/viewvc?view=rev&rev=554767
Log:
2007-07-09  Martin Sebor  <sebor@roguewave.com>

	* atomic_xchg.cpp (run_test): Documented algorithm used to compute
	the expected value of the shared variable manipulated by threads.

Modified:
    incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp

Modified: incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp?view=diff&rev=554767&r1=554766&r2=554767
==============================================================================
--- incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp (original)
+++ incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp Mon Jul  9 14:15:39 2007
@@ -294,11 +294,15 @@
         }
     }
 
-    // compute the expected result
+    // compute the expected result, "skipping" zeros by incrementing
+    // expect twice when it overflows and wraps around to 0 (zero is
+    // used as the lock variable in thread_routine() above)
     intT expect = intT (1);
 
-    for (unsigned long i = 0; i != (Args::nthreads_ * Args::nincr_) / 2U; ++i) {
-        if (!++expect)
+    const unsigned long nincr = (Args::nthreads_ * Args::nincr_) / 2U;
+        
+    for (unsigned long i = 0; i != nincr; ++i) {
+        if (intT () == ++expect)
             ++expect;
     }
 



Mime
View raw message