Changeset 21040

Show
Ignore:
Timestamp:
02/23/08 08:03:51 (9 months ago)
Author:
patrick
Message:

Fixed coding standard violations. Improved const correctness. Improved debug
output. No functional changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/vapor/vpr/Thread/ThreadPool.cpp

    r20974 r21040  
    6868// Constructor. 
    6969// --------------------------------------------------------------------------- 
    70 ThreadPool::ThreadPool (int numToStartWith) : readyThreads(0) 
     70ThreadPool::ThreadPool(const int numToStartWith) 
     71   : readyThreads(0) 
    7172{ 
    7273   //DebugLock.acquire(); 
    7374   vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) 
    74       << "vprThreadPool::vprThreadPool: Entering.\n" << vprDEBUG_FLUSH; 
     75      << "[vpr::ThreadPool::ThreadPool()] Entering.\n" << vprDEBUG_FLUSH; 
    7576   vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) 
    76       << "\tvprThreadPool::vprThreadPool: Number threads: " << numToStartWith 
    77       << std::endl << vprDEBUG_FLUSH; 
     77      << "\tNumber of threads: " << numToStartWith << std::endl 
     78      << vprDEBUG_FLUSH; 
    7879   //DebugLock.release(); 
    7980 
     
    8485 
    8586   //-- Start the initial # of threads ---// 
    86    for ( int index=0;index < numToStartWith;index++
     87   for ( int index = 0; index < numToStartWith; ++index
    8788   { 
    8889      addThread(); 
     
    115116{ 
    116117//   DebugLock.acquire(); 
    117    vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) << Thread::self() 
    118       << " vpr::ThreadPool::threadLoop: Entering." 
    119       << std::endl << vprDEBUG_FLUSH; 
     118   vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) 
     119      << "[vpr::ThreadPool::threadLoop()] Entering." << std::endl 
     120      << vprDEBUG_FLUSH; 
    120121//      vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << Thread::self() 
    121122//      << " vpr::ThreadPool::threadLoop: theThreadAsVoid:" 
     
    137138         finishedLock.acquire();       // Now there are threads working 
    138139      } 
    139       workingCount = workingCount + 1;    // Update thread count 
     140      ++workingCount;                  // Update thread count 
    140141      workingCountLock.release(); 
    141142 
     
    145146      // --- PROCESS EXIT OVERHEAD --- // 
    146147      workingCountLock.acquire();     // Get access to the working count 
    147       workingCount = workingCount - 1
     148      --workingCount
    148149      if ( workingCount == 0 ) 
    149150      { 
     
    158159// sleep on it.  Called by a child process when its work is done. 
    159160// --------------------------------------------------------------------------- 
    160 void ThreadPool::threadSleep (OneThread* theThread) 
     161void ThreadPool::threadSleep(OneThread* theThread) 
    161162{ 
    162163   listLock.acquire();               // acquire exclusive rights to threadList 
     
    175176// dispatching a thread. 
    176177// --------------------------------------------------------------------------- 
    177 OneThread* ThreadPool::getThread () 
     178OneThread* ThreadPool::getThread() 
    178179{ 
    179180   OneThread* theThread; 
     
    191192// --------------------------------------------------------------------------- 
    192193// --------------------------------------------------------------------------- 
    193 void ThreadPool::printList () 
     194void ThreadPool::printList() const 
    194195{ 
    195196   OneThread* curThread = listHead; 
     
    208209// --------------------------------------------------------------------------- 
    209210// --------------------------------------------------------------------------- 
    210 OneThread* ThreadPool::addThread () 
     211OneThread* ThreadPool::addThread() 
    211212{ 
    212213   static int numTimes = 0; 
    213214//    DebugLock.acquire(); 
    214    vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) << Thread::self() 
    215       << " vpr::ThreadPool::addThread: Entering: " << ++numTimes << std::endl 
    216       << vprDEBUG_FLUSH; 
     215   vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) 
     216      << "[vpr::ThreadPool::addThread()] Entering: " << ++numTimes 
     217      << std::endl << vprDEBUG_FLUSH; 
    217218//    DebugLock.release(); 
    218219 
     
    226227 
    227228//    DebugLock.acquire(); 
    228    vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << newThread->thread 
    229       << " vprThreadPool::addThread: List at end\n" << vprDEBUG_FLUSH; 
     229   vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) 
     230      << newThread->thread << " [vprThreadPool::addThread()] List at end\n" 
     231      << vprDEBUG_FLUSH; 
    230232   printList(); 
    231233//    DebugLock.release(); 
     
    234236} 
    235237 
    236  
    237 std::ostream& operator<< (std::ostream& outfile, vpr::OneThread& thread) 
     238std::ostream& operator<<(std::ostream& outfile, vpr::OneThread& thread) 
    238239{ 
    239240   outfile << thread.thread; 
  • juggler/trunk/modules/vapor/vpr/Thread/ThreadPool.h

    r20974 r21040  
    3939#include <vpr/vprConfig.h> 
    4040 
     41#include <iostream> 
     42 
    4143#include <vpr/Thread/Thread.h> 
    4244#include <vpr/Sync/Semaphore.h> 
     
    7375}; 
    7476 
    75  
    76 std::ostream& operator<< (std::ostream&, vpr::OneThread&); 
    77  
     77VPR_API(std::ostream&) operator<<(std::ostream&, vpr::OneThread&); 
    7878 
    7979/** \class ThreadPool ThreadPool.h vpr/Thread/ThreadPool.h 
     
    9393public: 
    9494   /** Constructor. */ 
    95    ThreadPool(int numToStartWith = 1); 
     95   ThreadPool(const int numToStartWith = 1); 
    9696 
    9797   ~ThreadPool(); 
     
    146146   } 
    147147 
    148    void printList()
     148   void printList() const
    149149 
    150150private: