dbertoni 01/02/02 14:50:41
Modified: c/Tests/Threads ThreadTest.cpp
Log:
Avoid synchronizing getCounter().
Revision Changes Path
1.6 +18 -6 xml-xalan/c/Tests/Threads/ThreadTest.cpp
Index: ThreadTest.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/Tests/Threads/ThreadTest.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ThreadTest.cpp 2001/02/02 22:24:40 1.5
+++ ThreadTest.cpp 2001/02/02 22:50:38 1.6
@@ -125,8 +125,6 @@
unsigned long
SynchronizedCounter::getCounter() const
{
- XMLMutexLock theLock(&m_mutex);
-
return m_counter;
}
@@ -258,22 +256,36 @@
}
}
+ clock_t theClock = 0;
+
if (theThreadInfo.size() == 0)
{
cerr << endl << "No threads were created!" << endl;
}
else
{
+ unsigned int theCheckCount = 0;
+
do
{
Sleep(2000);
- }
- while(theCounter.getCounter() != 0);
+
+ // Check a couple of times, just in case, since
+ // getCounter() is not synchronized...
+ if (theCounter.getCounter() == 0)
+ {
+ if (theCheckCount == 0)
+ {
+ theClock = clock();
+ }
- Sleep(2000);
+ ++theCheckCount;
+ }
+ }
+ while(theCheckCount < 2);
}
- cout << endl << "Clock after threads: " << clock() << endl;
+ cout << endl << "Clock after threads: " << theClock << endl;
}
catch(...)
{