Searches the pool of known threads for a thread whose id is equivalent to the given threadid. Compares thread ids with ThreadManager::compare().
| 200 | /// Searches the pool of known threads for a thread whose id is equivalent to |
| 201 | /// the given threadid. Compares thread ids with ThreadManager::compare(). |
| 202 | static Thread* getThreadById(U32 threadid) |
| 203 | { |
| 204 | AssertFatal(threadid != 0, "ThreadManager::getThreadById() Searching for a bad thread id."); |
| 205 | Thread* ret = NULL; |
| 206 | |
| 207 | ThreadManager &manager = *ManagedSingleton< ThreadManager >::instance(); |
| 208 | manager.poolLock.lock(); |
| 209 | Vector<Thread*> &pool = manager.threadPool; |
| 210 | for( S32 i = pool.size() - 1; i >= 0; i--) |
| 211 | { |
| 212 | Thread* p = pool[i]; |
| 213 | if(compare(p->getId(), threadid)) |
| 214 | { |
| 215 | ret = p; |
| 216 | break; |
| 217 | } |
| 218 | } |
| 219 | manager.poolLock.unlock(); |
| 220 | return ret; |
| 221 | } |
| 222 | |
| 223 | static Thread* getCurrentThread() |
| 224 | { |