You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2007/07/09 23:15:40 UTC
svn commit: r554767 - /incubator/stdcxx/trunk/tests/support/atomic_xchg.cpp
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 <se...@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;
}