Changeset 21040
- Timestamp:
- 02/23/08 08:03:51 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/vapor/vpr/Thread/ThreadPool.cpp
r20974 r21040 68 68 // Constructor. 69 69 // --------------------------------------------------------------------------- 70 ThreadPool::ThreadPool (int numToStartWith) : readyThreads(0) 70 ThreadPool::ThreadPool(const int numToStartWith) 71 : readyThreads(0) 71 72 { 72 73 //DebugLock.acquire(); 73 74 vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) 74 << " vprThreadPool::vprThreadPool:Entering.\n" << vprDEBUG_FLUSH;75 << "[vpr::ThreadPool::ThreadPool()] Entering.\n" << vprDEBUG_FLUSH; 75 76 vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) 76 << "\t vprThreadPool::vprThreadPool: Number threads: " << numToStartWith77 << std::endl <<vprDEBUG_FLUSH;77 << "\tNumber of threads: " << numToStartWith << std::endl 78 << vprDEBUG_FLUSH; 78 79 //DebugLock.release(); 79 80 … … 84 85 85 86 //-- Start the initial # of threads ---// 86 for ( int index =0;index < numToStartWith;index++)87 for ( int index = 0; index < numToStartWith; ++index ) 87 88 { 88 89 addThread(); … … 115 116 { 116 117 // 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; 120 121 // vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << Thread::self() 121 122 // << " vpr::ThreadPool::threadLoop: theThreadAsVoid:" … … 137 138 finishedLock.acquire(); // Now there are threads working 138 139 } 139 workingCount = workingCount + 1;// Update thread count140 ++workingCount; // Update thread count 140 141 workingCountLock.release(); 141 142 … … 145 146 // --- PROCESS EXIT OVERHEAD --- // 146 147 workingCountLock.acquire(); // Get access to the working count 147 workingCount = workingCount - 1;148 --workingCount; 148 149 if ( workingCount == 0 ) 149 150 { … … 158 159 // sleep on it. Called by a child process when its work is done. 159 160 // --------------------------------------------------------------------------- 160 void ThreadPool::threadSleep (OneThread* theThread)161 void ThreadPool::threadSleep(OneThread* theThread) 161 162 { 162 163 listLock.acquire(); // acquire exclusive rights to threadList … … 175 176 // dispatching a thread. 176 177 // --------------------------------------------------------------------------- 177 OneThread* ThreadPool::getThread ()178 OneThread* ThreadPool::getThread() 178 179 { 179 180 OneThread* theThread; … … 191 192 // --------------------------------------------------------------------------- 192 193 // --------------------------------------------------------------------------- 193 void ThreadPool::printList ()194 void ThreadPool::printList() const 194 195 { 195 196 OneThread* curThread = listHead; … … 208 209 // --------------------------------------------------------------------------- 209 210 // --------------------------------------------------------------------------- 210 OneThread* ThreadPool::addThread ()211 OneThread* ThreadPool::addThread() 211 212 { 212 213 static int numTimes = 0; 213 214 // DebugLock.acquire(); 214 vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) << Thread::self()215 << " vpr::ThreadPool::addThread: Entering: " << ++numTimes << std::endl216 << vprDEBUG_FLUSH;215 vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) 216 << "[vpr::ThreadPool::addThread()] Entering: " << ++numTimes 217 << std::endl << vprDEBUG_FLUSH; 217 218 // DebugLock.release(); 218 219 … … 226 227 227 228 // 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; 230 232 printList(); 231 233 // DebugLock.release(); … … 234 236 } 235 237 236 237 std::ostream& operator<< (std::ostream& outfile, vpr::OneThread& thread) 238 std::ostream& operator<<(std::ostream& outfile, vpr::OneThread& thread) 238 239 { 239 240 outfile << thread.thread; juggler/trunk/modules/vapor/vpr/Thread/ThreadPool.h
r20974 r21040 39 39 #include <vpr/vprConfig.h> 40 40 41 #include <iostream> 42 41 43 #include <vpr/Thread/Thread.h> 42 44 #include <vpr/Sync/Semaphore.h> … … 73 75 }; 74 76 75 76 std::ostream& operator<< (std::ostream&, vpr::OneThread&); 77 77 VPR_API(std::ostream&) operator<<(std::ostream&, vpr::OneThread&); 78 78 79 79 /** \class ThreadPool ThreadPool.h vpr/Thread/ThreadPool.h … … 93 93 public: 94 94 /** Constructor. */ 95 ThreadPool( int numToStartWith = 1);95 ThreadPool(const int numToStartWith = 1); 96 96 97 97 ~ThreadPool(); … … 146 146 } 147 147 148 void printList() ;148 void printList() const; 149 149 150 150 private:
