dbertoni    01/07/18 21:36:15

  Modified:    c/Tests/Threads ThreadTest.cpp
  Log:
  Removed use of std::vector<>.
  
  Revision  Changes    Path
  1.15      +15 -17    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ThreadTest.cpp    2001/06/21 15:36:37     1.14
  +++ ThreadTest.cpp    2001/07/19 04:36:15     1.15
  @@ -20,6 +20,10 @@
   
   
   
  +#include <Include/XalanAutoPtr.hpp>
  +
  +
  +
   #include <XalanTransformer/XalanTransformer.hpp>
   
   
  @@ -43,7 +47,6 @@
        using std::cerr;
        using std::cout;
        using std::endl;
  -     using std::vector;
   #endif
   
   
  @@ -140,12 +143,6 @@
        {
        }
   
  -     ThreadInfo(const ThreadInfo&    theSource) :
  -             m_threadNumber(theSource.m_threadNumber),
  -             m_counter(theSource.m_counter)
  -     {
  -     }
  -
        unsigned int                    m_threadNumber;
   
        SynchronizedCounter*    m_counter;
  @@ -238,12 +235,8 @@
   doThreads(long       theThreadCount)
   {
        cout << endl << "Starting " << theThreadCount << " threads." << endl;
  -
  -     typedef vector<ThreadInfo>              ThreadInfoVectorType;
  -
  -     ThreadInfoVectorType    theThreadInfo;
   
  -     theThreadInfo.reserve(theThreadCount);
  +     XalanArrayAutoPtr<ThreadInfo>   theThreadInfo(new 
ThreadInfo[theThreadCount]);
   
        try
        {
  @@ -251,14 +244,17 @@
   
                SynchronizedCounter             theCounter;
   
  -             for (long i = 0; i < theThreadCount; i++)
  +             long    i = 0;
  +
  +             while (i < theThreadCount)
                {
  -                     
theThreadInfo.push_back(ThreadInfoVectorType::value_type(i, &theCounter));
  +                     theThreadInfo[i].m_threadNumber = i;
  +                     theThreadInfo[i].m_counter = &theCounter;
   
   #if defined(WIN32)
   
                        const unsigned long             theThreadID =
  -                                     _beginthread(theThreadRoutine, 4096, 
reinterpret_cast<LPVOID>(&theThreadInfo.back()));
  +                                     _beginthread(theThreadRoutine, 4096, 
reinterpret_cast<LPVOID>(&theThreadInfo[i]));
   
                        if (theThreadID == unsigned(-1))
                        {
  @@ -269,7 +265,7 @@
   
                        pthread_t       theThread;
   
  -                     const int       theResult = pthread_create(&theThread, 
0, theThreadRoutine, (void*)&theThreadInfo.back());
  +                     const int       theResult = pthread_create(&theThread, 
0, theThreadRoutine, (void*)&theThreadInfo[i]);
   
                        if (theResult != 0)
                        {
  @@ -286,11 +282,13 @@
   #else
   #error Unsupported platform!
   #endif
  +
  +                     ++i;
                }
   
                clock_t         theClock = 0;
   
  -             if (theThreadInfo.size() == 0)
  +             if (i == 0)
                {
                        cerr << endl << "No threads were created!" << endl;
                }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to