using Winix::Lock object instead of Lock() method in ThreadManager

This commit is contained in:
Tomasz Sowa 2021-04-10 21:12:28 +02:00
parent 0e0c006d5a
commit 634cf07d44
1 changed files with 9 additions and 11 deletions

View File

@ -130,8 +130,7 @@ void ThreadManager::Add(BaseThread & pbase, const std::wstring & thread_name)
void ThreadManager::StartAll() void ThreadManager::StartAll()
{ {
synchro->Lock(); Winix::Lock lock(synchro);
int id = 0; int id = 0;
for(ThreadItem & item : thread_tab) for(ThreadItem & item : thread_tab)
@ -140,7 +139,7 @@ void ThreadManager::StartAll()
id += 1; id += 1;
} }
synchro->Unlock(); lock.Unlock();
were_started = true; were_started = true;
} }
@ -165,17 +164,16 @@ void ThreadManager::StopAll()
if( !were_started ) if( !were_started )
return; return;
// WakeUpThread() should be used with Lock/Unlock
synchro->Lock();
for(ThreadItem & item : thread_tab)
{ {
item.object->WakeUpThread(); Winix::Lock lock(synchro);
for(ThreadItem & item : thread_tab)
{
// WakeUpThread() should be used with Lock/Unlock
item.object->WakeUpThread();
}
} }
synchro->Unlock();
int id = 0; int id = 0;
for(ThreadItem & item : thread_tab) for(ThreadItem & item : thread_tab)