1
0
Fork 0

Use foreach() loops in thread.cpp

This commit is contained in:
Nukem 2015-03-16 22:47:40 -04:00
parent d38817c9ac
commit 722665fe53
1 changed files with 15 additions and 15 deletions

View File

@ -103,9 +103,9 @@ bool ThreadIsValid(DWORD dwThreadId)
{ {
SHARED_ACQUIRE(LockThreads); SHARED_ACQUIRE(LockThreads);
for(auto itr = threadList.begin(); itr != threadList.end(); itr++) for(auto & entry : threadList)
{ {
if(itr->ThreadId == dwThreadId) if(entry.ThreadId == dwThreadId)
return true; return true;
} }
@ -169,14 +169,14 @@ bool ThreadSetName(DWORD dwThreadId, const char* name)
EXCLUSIVE_ACQUIRE(LockThreads); EXCLUSIVE_ACQUIRE(LockThreads);
// Modifies a variable (name), so an exclusive lock is required // Modifies a variable (name), so an exclusive lock is required
for(auto itr = threadList.begin(); itr != threadList.end(); itr++) for(auto & entry : threadList)
{ {
if(itr->ThreadId == dwThreadId) if(entry.ThreadId == dwThreadId)
{ {
if(!name) if(!name)
name = ""; name = "";
strcpy_s(itr->threadName, name); strcpy_s(entry.threadName, name);
return true; return true;
} }
} }
@ -188,10 +188,10 @@ HANDLE ThreadGetHandle(DWORD dwThreadId)
{ {
SHARED_ACQUIRE(LockThreads); SHARED_ACQUIRE(LockThreads);
for(auto itr = threadList.begin(); itr != threadList.end(); itr++) for(auto & entry : threadList)
{ {
if(itr->ThreadId == dwThreadId) if(entry.ThreadId == dwThreadId)
return itr->Handle; return entry.Handle;
} }
// TODO: Set an assert if the handle is never found, // TODO: Set an assert if the handle is never found,
@ -204,10 +204,10 @@ DWORD ThreadGetId(HANDLE hThread)
SHARED_ACQUIRE(LockThreads); SHARED_ACQUIRE(LockThreads);
// Search for the ID in the local list // Search for the ID in the local list
for(auto itr = threadList.begin(); itr != threadList.end(); itr++) for(auto & entry : threadList)
{ {
if(itr->Handle == hThread) if(entry.Handle == hThread)
return itr->ThreadId; return entry.ThreadId;
} }
// Wasn't found, check with Windows // Wasn't found, check with Windows
@ -226,9 +226,9 @@ int ThreadSuspendAll()
SHARED_ACQUIRE(LockThreads); SHARED_ACQUIRE(LockThreads);
int count = 0; int count = 0;
for(auto itr = threadList.begin(); itr != threadList.end(); itr++) for(auto & entry : threadList)
{ {
if(SuspendThread(itr->Handle) != -1) if(SuspendThread(entry.Handle) != -1)
count++; count++;
} }
@ -243,9 +243,9 @@ int ThreadResumeAll()
SHARED_ACQUIRE(LockThreads); SHARED_ACQUIRE(LockThreads);
int count = 0; int count = 0;
for(auto itr = threadList.begin(); itr != threadList.end(); itr++) for(auto & entry : threadList)
{ {
if(ResumeThread(itr->Handle) != -1) if(ResumeThread(entry.Handle) != -1)
count++; count++;
} }