1
0
Fork 0
forked from suyu/suyu

Mutex: Moved ReleaseMutex iterator declaration to be inside while loop.

This commit is contained in:
bunnei 2014-06-06 00:13:50 -04:00
parent 8cac527c94
commit 780a443b08

View file

@ -100,11 +100,10 @@ bool ReleaseMutexForThread(Mutex* mutex, Handle thread) {
bool ReleaseMutex(Mutex* mutex) { bool ReleaseMutex(Mutex* mutex) {
MutexEraseLock(mutex); MutexEraseLock(mutex);
bool woke_threads = false; bool woke_threads = false;
std::vector<Handle>::iterator iter;
// Find the next waiting thread for the mutex... // Find the next waiting thread for the mutex...
while (!woke_threads && !mutex->waiting_threads.empty()) { while (!woke_threads && !mutex->waiting_threads.empty()) {
iter = mutex->waiting_threads.begin(); std::vector<Handle>::iterator iter = mutex->waiting_threads.begin();
woke_threads |= ReleaseMutexForThread(mutex, *iter); woke_threads |= ReleaseMutexForThread(mutex, *iter);
mutex->waiting_threads.erase(iter); mutex->waiting_threads.erase(iter);
} }