1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_framework.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32*cdf0e10cSrcweir // my own includes 33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_ 37*cdf0e10cSrcweir #include <threadhelp/transactionbase.hxx> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 40*cdf0e10cSrcweir #include <threadhelp/readguard.hxx> 41*cdf0e10cSrcweir #include <threadhelp/writeguard.hxx> 42*cdf0e10cSrcweir #include <threadhelp/transactionguard.hxx> 43*cdf0e10cSrcweir #include <macros/generic.hxx> 44*cdf0e10cSrcweir #include <macros/debug.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 47*cdf0e10cSrcweir // interface includes 48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 51*cdf0e10cSrcweir // other includes 52*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 53*cdf0e10cSrcweir #include <rtl/random.h> 54*cdf0e10cSrcweir #include <vos/process.hxx> 55*cdf0e10cSrcweir #include <vos/thread.hxx> 56*cdf0e10cSrcweir #include <rtl/ustring.hxx> 57*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 58*cdf0e10cSrcweir #include <osl/time.h> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #ifndef _OSL_INTERLOCK_H_ 61*cdf0e10cSrcweir #include <osl/interlock.h> 62*cdf0e10cSrcweir #endif 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include <vcl/event.hxx> 65*cdf0e10cSrcweir #include <vcl/svapp.hxx> 66*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 67*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 68*cdf0e10cSrcweir #include <stdio.h> 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 71*cdf0e10cSrcweir // const 72*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir #define LOGFILE "threadtest.log" 75*cdf0e10cSrcweir #define STATISTICS_FILE "threadtest_statistic.csv" 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 78*cdf0e10cSrcweir // namespace 79*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir using namespace ::rtl ; 82*cdf0e10cSrcweir using namespace ::osl ; 83*cdf0e10cSrcweir using namespace ::vos ; 84*cdf0e10cSrcweir using namespace ::framework ; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 87*cdf0e10cSrcweir // defines 88*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir /*---------------- Use follow defines to enable/disable some special features of this little test program! -------*/ 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir #define ENABLE_LOG 93*cdf0e10cSrcweir //#define ENABLE_THREADDELAY 94*cdf0e10cSrcweir #define ENABLE_REQUESTCOUNT 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /*----------------------------------------------------------------------------------------------------------------*/ 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir #ifdef ENABLE_LOG 99*cdf0e10cSrcweir #define LOG_SETA_START( NA, NID ) \ 100*cdf0e10cSrcweir { \ 101*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 102*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 103*cdf0e10cSrcweir OStringBuffer sLog(256); \ 104*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 105*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 106*cdf0e10cSrcweir sLog.append( NID ); \ 107*cdf0e10cSrcweir sLog.append( " ] call setA( " ); \ 108*cdf0e10cSrcweir sLog.append( NA ); \ 109*cdf0e10cSrcweir sLog.append( " )\n" ); \ 110*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir #define LOG_SETA_END( NA, EREASON, NID ) \ 114*cdf0e10cSrcweir { \ 115*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 116*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 117*cdf0e10cSrcweir OStringBuffer sLog(256); \ 118*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 119*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 120*cdf0e10cSrcweir sLog.append( NID ); \ 121*cdf0e10cSrcweir if( EREASON == E_NOREASON ) \ 122*cdf0e10cSrcweir sLog.append( " ] finish setA( " ); \ 123*cdf0e10cSrcweir else \ 124*cdf0e10cSrcweir sLog.append( " ] was refused at setA( "); \ 125*cdf0e10cSrcweir sLog.append( NA ); \ 126*cdf0e10cSrcweir sLog.append( " )\n" ); \ 127*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir #define LOG_GETA_START( NID ) \ 131*cdf0e10cSrcweir { \ 132*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 133*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 134*cdf0e10cSrcweir OStringBuffer sLog(256); \ 135*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 136*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 137*cdf0e10cSrcweir sLog.append( NID ); \ 138*cdf0e10cSrcweir sLog.append( " ] call getA()\n" ); \ 139*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir #define LOG_GETA_END( NRETURN, EREASON, NID ) \ 143*cdf0e10cSrcweir { \ 144*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 145*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 146*cdf0e10cSrcweir OStringBuffer sLog(256); \ 147*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 148*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 149*cdf0e10cSrcweir sLog.append( NID ); \ 150*cdf0e10cSrcweir if( EREASON == E_NOREASON ) \ 151*cdf0e10cSrcweir sLog.append( " ] finish getA() with " ); \ 152*cdf0e10cSrcweir else \ 153*cdf0e10cSrcweir sLog.append( " ] was refused at getA() with " ); \ 154*cdf0e10cSrcweir sLog.append( NRETURN ); \ 155*cdf0e10cSrcweir sLog.append( "\n" ); \ 156*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir #define LOG_WORKA_START( NA, NID ) \ 160*cdf0e10cSrcweir { \ 161*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 162*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 163*cdf0e10cSrcweir OStringBuffer sLog(256); \ 164*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 165*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 166*cdf0e10cSrcweir sLog.append( NID ); \ 167*cdf0e10cSrcweir sLog.append( " ] call workA( " ); \ 168*cdf0e10cSrcweir sLog.append( NA ); \ 169*cdf0e10cSrcweir sLog.append( " )\n" ); \ 170*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir #define LOG_WORKA_END( NRETURN, EREASON, NID ) \ 174*cdf0e10cSrcweir { \ 175*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 176*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 177*cdf0e10cSrcweir OStringBuffer sLog(256); \ 178*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 179*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 180*cdf0e10cSrcweir sLog.append( NID ); \ 181*cdf0e10cSrcweir if( EREASON == E_NOREASON ) \ 182*cdf0e10cSrcweir sLog.append( " ] finish workA() with " ); \ 183*cdf0e10cSrcweir else \ 184*cdf0e10cSrcweir sLog.append( " ] was refused at workA() with " ); \ 185*cdf0e10cSrcweir sLog.append( NRETURN ); \ 186*cdf0e10cSrcweir sLog.append( "\n" ); \ 187*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir #define LOG_INITEXCEPTION( SMETHOD, NID ) \ 191*cdf0e10cSrcweir { \ 192*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 193*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 194*cdf0e10cSrcweir OStringBuffer sLog(256); \ 195*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 196*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 197*cdf0e10cSrcweir sLog.append( NID ); \ 198*cdf0e10cSrcweir sLog.append( " ] get EInitException from \"" ); \ 199*cdf0e10cSrcweir sLog.append( SMETHOD ); \ 200*cdf0e10cSrcweir sLog.append( "\"\n" ); \ 201*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir #define LOG_CLOSEEXCEPTION( SMETHOD, NID ) \ 205*cdf0e10cSrcweir { \ 206*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 207*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 208*cdf0e10cSrcweir OStringBuffer sLog(256); \ 209*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 210*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 211*cdf0e10cSrcweir sLog.append( NID ); \ 212*cdf0e10cSrcweir sLog.append( " ] get ECloseException from \"" ); \ 213*cdf0e10cSrcweir sLog.append( SMETHOD ); \ 214*cdf0e10cSrcweir sLog.append( "\"\n" ); \ 215*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir #define LOG_INIT( NA, NID ) \ 219*cdf0e10cSrcweir { \ 220*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 221*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 222*cdf0e10cSrcweir OStringBuffer sLog(256); \ 223*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 224*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 225*cdf0e10cSrcweir sLog.append( NID ); \ 226*cdf0e10cSrcweir sLog.append( " ] initialize me with " ); \ 227*cdf0e10cSrcweir sLog.append( NA ); \ 228*cdf0e10cSrcweir sLog.append( "\n" ); \ 229*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir #define LOG_CLOSE( NID ) \ 233*cdf0e10cSrcweir { \ 234*cdf0e10cSrcweir sal_uInt32 nTimeStamp = osl_getGlobalTimer(); \ 235*cdf0e10cSrcweir ::osl::MutexGuard aLogGuard( m_aLogMutex ); \ 236*cdf0e10cSrcweir OStringBuffer sLog(256); \ 237*cdf0e10cSrcweir sLog.append( (sal_Int32)nTimeStamp ); \ 238*cdf0e10cSrcweir sLog.append( ": Thread[ " ); \ 239*cdf0e10cSrcweir sLog.append( NID ); \ 240*cdf0e10cSrcweir sLog.append( " ] close me\n" ); \ 241*cdf0e10cSrcweir WRITE_LOGFILE( LOGFILE, sLog.makeStringAndClear() ) \ 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir #else 244*cdf0e10cSrcweir #define LOG_SETA_START( NA, NID ) 245*cdf0e10cSrcweir #define LOG_SETA_END( NA, EREASON, NID ) 246*cdf0e10cSrcweir #define LOG_GETA_START( NID ) 247*cdf0e10cSrcweir #define LOG_GETA_END( NRETURN, EREASON, NID ) 248*cdf0e10cSrcweir #define LOG_WORKA_START( NA, NID ) 249*cdf0e10cSrcweir #define LOG_WORKA_END( NRETURN, EREASON, NID ) 250*cdf0e10cSrcweir #define LOG_INITEXCEPTION( SMETHOD, NID ) 251*cdf0e10cSrcweir #define LOG_CLOSEEXCEPTION( SMETHOD, NID ) 252*cdf0e10cSrcweir #define LOG_INIT( NA, NID ) 253*cdf0e10cSrcweir #define LOG_CLOSE( NID ) 254*cdf0e10cSrcweir #endif 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 257*cdf0e10cSrcweir // declarations 258*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir sal_uInt16 getRandomValue() 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir // Get new random value for thread-sleep! 263*cdf0e10cSrcweir // See run() for further informations. 264*cdf0e10cSrcweir // Always calculate a new random number. 265*cdf0e10cSrcweir sal_uInt16 nValue; 266*cdf0e10cSrcweir rtlRandomPool aPool = rtl_random_createPool(); 267*cdf0e10cSrcweir rtl_random_getBytes ( aPool, &nValue, 2 ); 268*cdf0e10cSrcweir rtl_random_destroyPool ( aPool ); 269*cdf0e10cSrcweir return nValue; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir /*-************************************************************************************************************//** 273*cdf0e10cSrcweir @descr This class is used from different threads at the same time. 274*cdf0e10cSrcweir We start working after calling init() first(!) ... 275*cdf0e10cSrcweir and finish it by calling close(). It exist two methods for reading/writing an 276*cdf0e10cSrcweir internal variable "A". Another function workA() do both things at the same time. 277*cdf0e10cSrcweir All public methods log information in a file if DO_LOG is defined. 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir @attention Our public base class FaiRWLockBase is a struct with a RWLock as member. 280*cdf0e10cSrcweir This member can be used by guards to safe access at internal variables 281*cdf0e10cSrcweir in interface methods. 282*cdf0e10cSrcweir Another baseclass is the TransactionBase. They support rejection of wrong calls at wrong time. 283*cdf0e10cSrcweir e.g. calls after closing object! 284*cdf0e10cSrcweir *//*-*************************************************************************************************************/ 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir class ThreadSafeClass : private ThreadHelpBase 287*cdf0e10cSrcweir , private TransactionBase 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir public: 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir ThreadSafeClass (); 293*cdf0e10cSrcweir ~ThreadSafeClass(); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir // This methods are used from differnt threads 296*cdf0e10cSrcweir // to test this class. 297*cdf0e10cSrcweir void init ( sal_Int32 nA , 298*cdf0e10cSrcweir sal_Int32 nThreadID ); 299*cdf0e10cSrcweir void close ( sal_Int32 nThreadID ); 300*cdf0e10cSrcweir void setA ( sal_Int32 nA , 301*cdf0e10cSrcweir sal_Int32 nThreadID ); 302*cdf0e10cSrcweir sal_Int32 getA ( sal_Int32 nThreadID ); 303*cdf0e10cSrcweir sal_Int32 workA ( sal_Int32 nA , 304*cdf0e10cSrcweir sal_Int32 nThreadID ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 307*cdf0e10cSrcweir // This methods are used for statistics only! 308*cdf0e10cSrcweir sal_Int32 getReadCount () { return m_nReadCount; } 309*cdf0e10cSrcweir sal_Int32 getWriteCount() { return m_nWriteCount; } 310*cdf0e10cSrcweir #endif 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir private: 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir sal_Int32 m_nA ; /// test member fro reading/writing 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir #ifdef ENABLE_LOG 317*cdf0e10cSrcweir ::osl::Mutex m_aLogMutex ; /// mutex to serialize writing log file! 318*cdf0e10cSrcweir #endif 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 321*cdf0e10cSrcweir oslInterlockedCount m_nReadCount ; /// statistic variables to count read/write requests 322*cdf0e10cSrcweir oslInterlockedCount m_nWriteCount ; 323*cdf0e10cSrcweir #endif 324*cdf0e10cSrcweir }; 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 327*cdf0e10cSrcweir ThreadSafeClass::ThreadSafeClass() 328*cdf0e10cSrcweir : ThreadHelpBase ( ) 329*cdf0e10cSrcweir , TransactionBase ( ) 330*cdf0e10cSrcweir , m_nA ( 0 ) 331*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 332*cdf0e10cSrcweir , m_nReadCount ( 0 ) 333*cdf0e10cSrcweir , m_nWriteCount ( 0 ) 334*cdf0e10cSrcweir #endif 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 339*cdf0e10cSrcweir ThreadSafeClass::~ThreadSafeClass() 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 344*cdf0e10cSrcweir void ThreadSafeClass::init( sal_Int32 nA, sal_Int32 nThreadID ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir // Look for multiple calls of this method first! 347*cdf0e10cSrcweir // Use E_SOFTEXCEPTIONS to disable automaticly throwing of exceptions for some working modes. 348*cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS ); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir // Set write lock for setting internal member AND 351*cdf0e10cSrcweir // protect changing of working mode! 352*cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 353*cdf0e10cSrcweir LOG_INIT( nA, nThreadID ) 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir // OK, it must be the first call and we are synchronized with all other threads by using the write lock! 356*cdf0e10cSrcweir // Otherwise (e.g. if working mode == E_WORK) we get a exception and follow lines are never called. 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // We can set our member and change the working mode now. 359*cdf0e10cSrcweir m_nA = nA; 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir aWriteLock.unlock(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir m_aTransactionManager.setWorkingMode( E_WORK ); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 367*cdf0e10cSrcweir void ThreadSafeClass::close( sal_Int32 nThreadID ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir // We must look for multiple calls of this method. 370*cdf0e10cSrcweir // Try to register this method as a transaction. 371*cdf0e10cSrcweir // In combination with E_HARDEXCEPTIONS only working mode E_WORK pass this barrier. 372*cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 373*cdf0e10cSrcweir aTransaction.stop(); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir // Change working mode to BEFORECLOSE to enable rejection of normal interface calls 376*cdf0e10cSrcweir // and enable SOFTEXCEPTION mode for some impl- or helper methods! 377*cdf0e10cSrcweir // Attention: We must stop successful registered transaction first ... 378*cdf0e10cSrcweir // because setWorkingMode() blocks and wait for all current existing ones! 379*cdf0e10cSrcweir m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir // Make it threadsafe. 382*cdf0e10cSrcweir // It must be an exclusiv access! => WriteLock! 383*cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir LOG_CLOSE( nThreadID ) 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir // Now we are alone ... 388*cdf0e10cSrcweir // All further calls to this object are rejected ... 389*cdf0e10cSrcweir // (not all ... some special ones can work by using E_SOFTEXCEPTIONS!) 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir // Deinitialize all member and set working mode to E_CLOSE. 392*cdf0e10cSrcweir m_nA = 0; 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir aWriteLock.unlock(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir m_aTransactionManager.setWorkingMode( E_CLOSE ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 400*cdf0e10cSrcweir void ThreadSafeClass::setA( sal_Int32 nA, sal_Int32 nThreadID ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir // Register this method as a transaction to prevent code against wrong calls 403*cdf0e10cSrcweir // after close() or before init()! 404*cdf0e10cSrcweir ERejectReason eReason; 405*cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_NOEXCEPTIONS, &eReason ); 406*cdf0e10cSrcweir if( eReason == E_NOREASON ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir // Make it threadsafe. 409*cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir LOG_SETA_START( nA, nThreadID ) 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir // This object is ready for working and we have full write access. 414*cdf0e10cSrcweir // We can work with our member. 415*cdf0e10cSrcweir m_nA = nA; 416*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 417*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nWriteCount ); 418*cdf0e10cSrcweir #endif 419*cdf0e10cSrcweir LOG_SETA_END( nA, eReason, nThreadID ) 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 424*cdf0e10cSrcweir sal_Int32 ThreadSafeClass::getA( sal_Int32 nThreadID ) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir // Register this method as a transaction to prevent code against wrong calls 427*cdf0e10cSrcweir // after close() or before init()! 428*cdf0e10cSrcweir sal_Int32 nReturn = 0; 429*cdf0e10cSrcweir ERejectReason eReason; 430*cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_NOEXCEPTIONS, &eReason ); 431*cdf0e10cSrcweir if( eReason == E_NOREASON ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir // Make it threadsafe. 434*cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir LOG_GETA_START( nThreadID ) 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir // This object is ready for working and we have a read access. 439*cdf0e10cSrcweir // We can work with our member. 440*cdf0e10cSrcweir nReturn = m_nA; 441*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 442*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nReadCount ); 443*cdf0e10cSrcweir #endif 444*cdf0e10cSrcweir LOG_GETA_END( nReturn, eReason, nThreadID ) 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir return nReturn; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 450*cdf0e10cSrcweir sal_Int32 ThreadSafeClass::workA( sal_Int32 nA , 451*cdf0e10cSrcweir sal_Int32 nThreadID ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir // Register this method as a transaction to prevent code against wrong calls 454*cdf0e10cSrcweir // after close() or before init()! 455*cdf0e10cSrcweir sal_Int32 nReturn = 0; 456*cdf0e10cSrcweir ERejectReason eReason; 457*cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_NOEXCEPTIONS, &eReason ); 458*cdf0e10cSrcweir if( eReason == E_NOREASON ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir // This method test the downgrade-mechanism of used lock implementation! 461*cdf0e10cSrcweir // Make it threadsafe. 462*cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir LOG_WORKA_START( nA, nThreadID ) 465*cdf0e10cSrcweir // We have write access to our member. 466*cdf0e10cSrcweir // Set new value. 467*cdf0e10cSrcweir m_nA = nA; 468*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 469*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nWriteCount ); 470*cdf0e10cSrcweir #endif 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir // Downgrade write access to read access and read the set value again. 473*cdf0e10cSrcweir // This call can't be rejected - but it can fail! 474*cdf0e10cSrcweir aWriteLock.downgrade(); 475*cdf0e10cSrcweir nReturn = m_nA; 476*cdf0e10cSrcweir #ifdef ENABLE_REQUESTCOUNT 477*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nReadCount ); 478*cdf0e10cSrcweir #endif 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir LOG_WORKA_END( nReturn, eReason, nThreadID ) 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir return nReturn; 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir /*-****************************************************************************************************//** 486*cdf0e10cSrcweir @descr Every thread instance of these class lopp from 0 up to "nLoops". 487*cdf0e10cSrcweir He sleep for a random time and work with given test class "pClass" then. 488*cdf0e10cSrcweir We use random values for waiting for better results! 489*cdf0e10cSrcweir Otherwise all threads are sychron after first 2,3...5 calls - I think! 490*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir class TestThread : public OThread 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir public: 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir TestThread( ThreadSafeClass* pClass , 497*cdf0e10cSrcweir sal_Int32 nLoops , 498*cdf0e10cSrcweir Condition* pListener , 499*cdf0e10cSrcweir sal_Bool bOwner = sal_False ); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir private: 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir virtual void SAL_CALL run (); 504*cdf0e10cSrcweir virtual void SAL_CALL onTerminated (); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir private: 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir ThreadSafeClass* m_pClass ; 509*cdf0e10cSrcweir sal_Int32 m_nLoops ; 510*cdf0e10cSrcweir sal_Int32 m_nThreadID ; 511*cdf0e10cSrcweir Condition* m_pListener ; 512*cdf0e10cSrcweir sal_Bool m_bOwner ; 513*cdf0e10cSrcweir }; 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 516*cdf0e10cSrcweir TestThread::TestThread( ThreadSafeClass* pClass , 517*cdf0e10cSrcweir sal_Int32 nLoops , 518*cdf0e10cSrcweir Condition* pListener , 519*cdf0e10cSrcweir sal_Bool bOwner ) 520*cdf0e10cSrcweir : m_pClass ( pClass ) 521*cdf0e10cSrcweir , m_nLoops ( nLoops ) 522*cdf0e10cSrcweir , m_pListener ( pListener ) 523*cdf0e10cSrcweir , m_bOwner ( bOwner ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 528*cdf0e10cSrcweir void SAL_CALL TestThread::run() 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir // Get ID of this thread. 531*cdf0e10cSrcweir // Is used for logging information ... 532*cdf0e10cSrcweir m_nThreadID = getCurrentIdentifier(); 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir // If we are the owner of given pClass 535*cdf0e10cSrcweir // we must initialize ... and close 536*cdf0e10cSrcweir // it. See at the end of this method too. 537*cdf0e10cSrcweir if( m_bOwner == sal_True ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir m_pClass->init( 0, m_nThreadID ); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir #ifdef ENABLE_THREADDELAY 543*cdf0e10cSrcweir TimeValue nDelay ; 544*cdf0e10cSrcweir #endif 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir sal_Int32 nA ; 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir for( sal_Int32 nCount=0; nCount<m_nLoops; ++nCount ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir // Work with class. 551*cdf0e10cSrcweir // Use random to select called method. 552*cdf0e10cSrcweir nA = (sal_Int32)getRandomValue(); 553*cdf0e10cSrcweir if( nA % 5 == 0 ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir //nA = m_pClass->workA( nA, m_nThreadID ); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir else 558*cdf0e10cSrcweir if( nA % 3 == 0 ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir m_pClass->setA( nA, m_nThreadID ); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir else 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir nA = m_pClass->getA( m_nThreadID ); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir #ifdef ENABLE_THREADDELAY 567*cdf0e10cSrcweir // Sleep - use random value to do that too! 568*cdf0e10cSrcweir nDelay.Seconds = 0; 569*cdf0e10cSrcweir nDelay.Nanosec = getRandomValue(); 570*cdf0e10cSrcweir sleep( nDelay ); 571*cdf0e10cSrcweir #endif 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir // Don't forget to "close" teset object if you are the owner! 575*cdf0e10cSrcweir if( m_bOwner == sal_True ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir m_pClass->close( m_nThreadID ); 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 582*cdf0e10cSrcweir void SAL_CALL TestThread::onTerminated() 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir // Destroy yourself if you finished. 585*cdf0e10cSrcweir // But don't forget to call listener before. 586*cdf0e10cSrcweir m_pListener->set(); 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir m_pClass = NULL; 589*cdf0e10cSrcweir m_pListener = NULL; 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir delete this; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir /*-****************************************************************************************************//** 595*cdf0e10cSrcweir @descr This is our test application. 596*cdf0e10cSrcweir We create one ThreadSafeClass object and a lot of threads 597*cdf0e10cSrcweir which use it at different times. 598*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir struct ThreadInfo 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir Condition* pCondition ; 603*cdf0e10cSrcweir TestThread* pThread ; 604*cdf0e10cSrcweir }; 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir class TestApplication : public Application 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir public: 609*cdf0e10cSrcweir void Main ( ); 610*cdf0e10cSrcweir sal_Int32 measureTime ( sal_Int32 nThreadCount , 611*cdf0e10cSrcweir sal_Int32 nOwner , 612*cdf0e10cSrcweir sal_Int32 nLoops=0 ); 613*cdf0e10cSrcweir }; 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 616*cdf0e10cSrcweir // definition 617*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir TestApplication aApplication; 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 622*cdf0e10cSrcweir // This function start "nThreadCount" threads to use same test class. 623*cdf0e10cSrcweir // You can specify the owner thread of this test class which start/stop it by using "nOwner". [1..nThreadcount]! 624*cdf0e10cSrcweir // If you specify "nLoops" different from 0 we use it as loop count for every started thread. 625*cdf0e10cSrcweir // Otherwise we work with random values. 626*cdf0e10cSrcweir sal_Int32 TestApplication::measureTime( sal_Int32 nThreadCount , 627*cdf0e10cSrcweir sal_Int32 nOwner , 628*cdf0e10cSrcweir sal_Int32 nLoops ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir // This is the class which should be tested. 631*cdf0e10cSrcweir ThreadSafeClass aClass; 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir // Create list of threads. 634*cdf0e10cSrcweir ThreadInfo* pThreads = new ThreadInfo[nThreadCount]; 635*cdf0e10cSrcweir sal_Int32 nLoopCount = nLoops ; 636*cdf0e10cSrcweir sal_Bool bOwner = sal_False ; 637*cdf0e10cSrcweir for( sal_Int32 nI=0; nI<nThreadCount; ++nI ) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir // If nLoops==0 => we must use random value; otherwise we must use given count ... 640*cdf0e10cSrcweir if( nLoops == 0 ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir nLoopCount = getRandomValue(); 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir // Search owner of class. 645*cdf0e10cSrcweir bOwner = sal_False; 646*cdf0e10cSrcweir if( nOwner == nI ) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir bOwner = sal_True; 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir // initialize condition. 651*cdf0e10cSrcweir pThreads[nI].pCondition = new Condition; 652*cdf0e10cSrcweir // Initialize thread. 653*cdf0e10cSrcweir pThreads[nI].pThread = new TestThread( &aClass, nLoopCount, pThreads[nI].pCondition, bOwner ); 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir // Start clock to get information about used time. 657*cdf0e10cSrcweir sal_uInt32 nStartTime ; 658*cdf0e10cSrcweir sal_uInt32 nEndTime ; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir nStartTime = osl_getGlobalTimer(); 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir // Start threads ... 663*cdf0e10cSrcweir for( nI=0; nI<nThreadCount; ++nI ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir pThreads[nI].pThread->create(); 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir // Wait for threads ... 669*cdf0e10cSrcweir for( nI=0; nI<nThreadCount; ++nI ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir pThreads[nI].pCondition->wait(); 672*cdf0e10cSrcweir delete pThreads[nI].pCondition; 673*cdf0e10cSrcweir pThreads[nI].pCondition = NULL; 674*cdf0e10cSrcweir pThreads[nI].pThread = NULL; 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir delete[] pThreads; 678*cdf0e10cSrcweir pThreads = NULL; 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir nEndTime = osl_getGlobalTimer(); 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir // Calc used time and return it. [ms] 683*cdf0e10cSrcweir return( nEndTime-nStartTime ); 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 687*cdf0e10cSrcweir void TestApplication::Main() 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir sal_Int32 nTestCount = 0; /// count of calling "measureTime()" 690*cdf0e10cSrcweir sal_Int32 nThreadCount = 0; /// count of used threads by "measure..." 691*cdf0e10cSrcweir sal_Int32 nLoops = 0; /// loop count for every thread 692*cdf0e10cSrcweir sal_Int32 nOwner = 0; /// number of owner thread 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir // Parse command line. 695*cdf0e10cSrcweir // Attention: All parameter are required and must exist! 696*cdf0e10cSrcweir // syntax: "threadtest.exe <testcount> <threadcount> <loops> <owner>" 697*cdf0e10cSrcweir OStartupInfo aInfo ; 698*cdf0e10cSrcweir OUString sArgument ; 699*cdf0e10cSrcweir sal_Int32 nArgument ; 700*cdf0e10cSrcweir sal_Int32 nCount = aInfo.getCommandArgCount(); 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir LOG_ASSERT2( nCount!=4 ,"TestApplication::Main()" , "Wrong argument line detected!") 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir for( nArgument=0; nArgument<nCount; ++nArgument ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir aInfo.getCommandArg( nArgument, sArgument ); 707*cdf0e10cSrcweir if( nArgument== 0 ) nTestCount =sArgument.toInt32(); 708*cdf0e10cSrcweir if( nArgument== 1 ) nThreadCount=sArgument.toInt32(); 709*cdf0e10cSrcweir if( nArgument== 2 ) nLoops =sArgument.toInt32(); 710*cdf0e10cSrcweir if( nArgument== 3 ) nOwner =sArgument.toInt32(); 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir LOG_ASSERT2( nTestCount==0||nThreadCount==0||nLoops==0||nOwner==0,"TestApplication::Main()", "Wrong argument value detected!" ) 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir // Start test. 716*cdf0e10cSrcweir OStringBuffer sBuf(256); 717*cdf0e10cSrcweir sal_Int32 nTime=0; 718*cdf0e10cSrcweir sBuf.append( "Nr.\tTime\tThreadCount\tLoops\tOwner\n" ); 719*cdf0e10cSrcweir for( sal_Int32 nI=1; nI<=nTestCount; ++nI ) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir nTime = measureTime( nThreadCount, nOwner, nLoops ); 722*cdf0e10cSrcweir sBuf.append( nI ); 723*cdf0e10cSrcweir sBuf.append( "\t" ); 724*cdf0e10cSrcweir sBuf.append( nTime ); 725*cdf0e10cSrcweir sBuf.append( "\t" ); 726*cdf0e10cSrcweir sBuf.append( nThreadCount ); 727*cdf0e10cSrcweir sBuf.append( "\t" ); 728*cdf0e10cSrcweir sBuf.append( nLoops ); 729*cdf0e10cSrcweir sBuf.append( "\t" ); 730*cdf0e10cSrcweir sBuf.append( nOwner ); 731*cdf0e10cSrcweir sBuf.append( "\n" ); 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir WRITE_LOGFILE( STATISTICS_FILE, sBuf.makeStringAndClear() ); 735*cdf0e10cSrcweir LOG_ERROR( "TApplication::Main()", "Test finish successful!" ) 736*cdf0e10cSrcweir } 737